use same example for objc
This commit is contained in:
parent
9ec521a6de
commit
72dd2ef364
14
README.md
14
README.md
@ -28,11 +28,17 @@ socket.connect()
|
||||
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:nil];
|
||||
|
||||
[socket on:@"connect" callback:^(NSArray* data, void (^ack)(NSArray*)) {
|
||||
NSLog(@"connected");
|
||||
[socket emit:@"echo" withItems:@[@"echo test"]];
|
||||
[socket emitWithAck:@"ackack" withItems:@[@1]](10, ^(NSArray* data) {
|
||||
NSLog(@"Got ack");
|
||||
NSLog(@"socket connected");
|
||||
}];
|
||||
|
||||
[socket on:@"currentAmount" callback:^(NSArray* data, void (^ack)(NSArray*)) {
|
||||
double cur = [[data objectAtIndex:0] floatValue];
|
||||
|
||||
[socket emitWithAck:@"canUpdate" withItems:@[@(cur)]](0, ^(NSArray* data) {
|
||||
[socket emit:@"update" withItems:@[@(cur + 2.50)]];
|
||||
});
|
||||
|
||||
ack(@[@"Got your ack, ", @"dude"]);
|
||||
}];
|
||||
|
||||
[socket connect];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user