File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,18 @@ socket.connect()
27
27
``` objective-c
28
28
SocketIOClient* socket = [[SocketIOClient alloc ] initWithSocketURL: @"localhost:8080" options: nil ] ;
29
29
30
- [ socket on: @"connect" callback: ^(NSArray* data, void (^ack)(NSArray* )) {
31
- NSLog(@"connected");
32
- [ socket emit:@"echo" withItems:@[ @"echo test"]] ;
33
- [ socket emitWithAck:@"ackack" withItems:@[ @1 ]] (10, ^(NSArray* data) {
34
- NSLog(@"Got ack");
30
+ [ socket on:@"connect" callback:^(NSArray* data, void (^ack)(NSArray* )) {
31
+ NSLog(@"socket connected");
32
+ }] ;
33
+
34
+ [ socket on:@"currentAmount" callback:^(NSArray* data, void (^ack)(NSArray* )) {
35
+ double cur = [[ data objectAtIndex:0] floatValue] ;
36
+
37
+ [socket emitWithAck:@"canUpdate" withItems:@[@(cur)]](0, ^(NSArray* data) {
38
+ [socket emit:@"update" withItems:@[@(cur + 2.50)]];
35
39
});
40
+
41
+ ack (@[ @"Got your ack, ", @"dude"] );
36
42
}] ;
37
43
38
44
[ socket connect] ;
You can’t perform that action at this time.
0 commit comments