Skip to content

Commit eb47dca

Browse files
committed
show how to test for ack timeouts
1 parent 36db2ff commit eb47dca

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

README.md

+9-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Socket.IO-client for iOS/OS X.
55

66
## Example
7-
```swift
7+
```
88
import SocketIO
99
1010
let 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

0 commit comments

Comments
 (0)