#import "HelloWorldSubExample.h"
@implementation HelloWorldSubExample
@synthesize msgCount;
- (id)initWithExampleInterface:(ExampleInterface *)exampleInterface {
self = [super initWithExampleInterface:exampleInterface];
self.name = @"HelloWorldSub";
self.description = @"Demonstrates the basics of session creation, "
@"connection and receiving direct messages from a topic";
[self.parameters addParameter:PARAMETER_DESTINATION_TOPIC];
[self.parameters removeParameter:PARAMETER_PASSWORD];
[self.parameters removeParameter:PARAMETER_COMPRESSION];
[self.parameters removeParameter:PARAMETER_LOGGING_LEVEL];
return self;
}
messageReceiveCallbackWithSession:
userData:(void *)user_p {
char buffer[5000];
self.msgCount++;
}
eventInfo:
userData:(void *)user_p {
}
- (void)run {
[super run];
const char *sessionProps[20];
int propIndex = 0;
self.msgCount = 0;
&context_p, &contextFuncInfo,
sizeof(contextFuncInfo));
propIndex = 0;
sessionProps[propIndex++] =
[[self.parameters parameterWithId:PARAMETER_HOST].value
cStringUsingEncoding:NSASCIIStringEncoding];
sessionProps[propIndex++] =
[[self.parameters parameterWithId:PARAMETER_VPN].value
cStringUsingEncoding:NSASCIIStringEncoding];
sessionProps[propIndex++] =
[[self.parameters parameterWithId:PARAMETER_USERNAME].value
cStringUsingEncoding:NSASCIIStringEncoding];
sessionProps[propIndex] = NULL;
&sessionFuncInfo, sizeof(sessionFuncInfo));
[[self.parameters parameterWithId:PARAMETER_DESTINATION_TOPIC].value
cStringUsingEncoding:NSASCIIStringEncoding]);
while (self.msgCount < 1 &&
!self.requestCancel) {
[NSThread sleepForTimeInterval:1];
}
[[self.parameters parameterWithId:PARAMETER_DESTINATION_TOPIC].value
cStringUsingEncoding:NSASCIIStringEncoding]);
[self cleanup];
}
@end