NSURL* url = [[NSURL alloc] initWithString:@"http://192.168.1.251:8080"];
_socket = [[SocketIOClient alloc] initWithSocketURL:url config:@{@"log": @YES, @"forcePolling": @YES,@"namespace":@"/test"}]
[_socket on:@"connect" callback:^(NSArray* data, SocketAckEmitter* ack) {
NSLog(@"socket connected");
}];
[_socket on:@"currentAmount" callback:^(NSArray* data, SocketAckEmitter* ack) {
double cur = [[data objectAtIndex:0] floatValue];
[[_socket emitWithAck:@"canUpdate" with:@[@(cur)]] timingOutAfter:0 callback:^(NSArray* data) {
[_socket emit:@"update" with:@[@{@"amount": @(cur + 2.50)}]];
}];
[ack with:@[@"Got your currentAmount, ", @"dude"]];
}];
[_socket connect];
我用了官方的,但一直不能连接服务器。求助各位大神,有没有谁用过socket.io,求一个小demo,最好是OC 的,官方的例子跑不通。(QQ:1072864875)