File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change 44Socket.IO-client for iOS/OS X.
55
66## Example
7- ``` swift
7+ ```
88import SocketIO
99
1010let manager = SocketManager(socketURL: URL(string: "http://localhost:8080")!, config: [.log(true), .compress])
@@ -18,6 +18,10 @@ socket.on("currentAmount") {data, ack in
1818 guard let cur = data[0] as? Double else { return }
1919
2020 socket.emitWithAck("canUpdate", cur).timingOut(after: 0) {data in
21+ if data.first as? String == SocketAckValue.noAck {
22+ // Handle ack timeout
23+ }
24+
2125 socket.emit("update", ["amount": cur + 2.50])
2226 }
2327
@@ -43,6 +47,10 @@ SocketIOClient* socket = manager.defaultSocket;
4347 double cur = [[ data objectAtIndex:0] floatValue] ;
4448
4549 [[socket emitWithAck:@"canUpdate" with:@[@(cur)]] timingOutAfter:0 callback:^(NSArray* data) {
50+ if ([[data[0] description] isEqualToString:@"NO ACK"]) {
51+ // Handle ack timeout
52+ }
53+
4654 [socket emit:@"update" with:@[@{@"amount": @(cur + 2.50)}]];
4755 }];
4856
You can’t perform that action at this time.
0 commit comments