Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 7d8eb6f

Browse files
committedMay 8, 2017
ack emits should allow custom types
1 parent dd2167a commit 7d8eb6f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed
 

‎Source/SocketAckEmitter.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,18 @@ public final class SocketAckEmitter : NSObject {
4848

4949
/// Call to ack receiving this event.
5050
///
51+
/// If an error occurs trying to transform `items` into their socket representation, a `SocketClientEvent.error`
52+
/// will be emitted. The structure of the error data is `[ackNum, items, theError]`
53+
///
5154
/// - parameter items: A variable number of items to send when acking.
5255
public func with(_ items: SocketData...) {
5356
guard ackNum != -1 else { return }
5457

55-
socket.emitAck(ackNum, with: items)
58+
do {
59+
socket.emitAck(ackNum, with: try items.map({ try $0.socketRepresentation() }))
60+
} catch let err {
61+
socket.handleClientEvent(.error, data: [ackNum, items, err])
62+
}
5663
}
5764

5865
/// Call to ack receiving this event.

0 commit comments

Comments
 (0)
Please sign in to comment.