#import "HelloWorldWebSubExample.h"
@implementation HelloWorldWebSubExample
@synthesize msgCount;
- (id)initWithExampleInterface:(ExampleInterface *)exampleInterface {
self = [super initWithExampleInterface:exampleInterface];
self.name = @"HelloWorldWebSub";
self.description = @"Demonstrates the basics of web messaging session "
@"creation, connection and receiving a direct message from a topic";
[self.parameters parameterWithId:PARAMETER_HOST].value =
@"http://192.168.168.136";
[self.parameters addParameter:PARAMETER_DESTINATION_TOPIC];
[self.parameters addParameter:PARAMETER_WEB_PROTOCOL];
[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;
if (![[[[self.parameters parameterWithId:PARAMETER_HOST].value
substringToIndex:4] lowercaseString] isEqualToString:@"http"] &&
![[[[self.parameters parameterWithId:PARAMETER_HOST].value
substringToIndex:4] lowercaseString] isEqualToString:@"ws"]) {
"This sample supports HTTP or WS transport protocols only.");
}
&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];
if (![[self.parameters parameterWithId:PARAMETER_WEB_PROTOCOL].value
isEqualToString:@""]) {
sessionProps[propIndex++] =
sessionProps[propIndex++] =
[[self.parameters parameterWithId:PARAMETER_WEB_PROTOCOL].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