Skip to content

Commit 72dd2ef

Browse files
committed
use same example for objc
1 parent 9ec521a commit 72dd2ef

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

README.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,18 @@ socket.connect()
2727
```objective-c
2828
SocketIOClient* socket = [[SocketIOClient alloc] initWithSocketURL:@"localhost:8080" options:nil];
2929

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)]];
3539
});
40+
41+
ack(@[@"Got your ack, ", @"dude"]);
3642
}];
3743

3844
[socket connect];

0 commit comments

Comments
 (0)