@@ -212,6 +212,19 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
212
212
/// - parameter items: The items to send with this event. May be left out.
213
213
/// - parameter completion: Callback called on transport write completion.
214
214
open func emit( _ event: String , _ items: SocketData ... , completion: ( ( ) -> ( ) ) ? = nil ) {
215
+ emit ( event, with: items, completion: completion)
216
+ }
217
+
218
+ /// Send an event to the server, with optional data items and optional write completion handler.
219
+ ///
220
+ /// If an error occurs trying to transform `items` into their socket representation, a `SocketClientEvent.error`
221
+ /// will be emitted. The structure of the error data is `[eventName, items, theError]`
222
+ ///
223
+ /// - parameter event: The event to send.
224
+ /// - parameter items: The items to send with this event. May be left out.
225
+ /// - parameter completion: Callback called on transport write completion.
226
+ open func emit( _ event: String , with items: [ SocketData ] , completion: ( ( ) -> ( ) ) ? ) {
227
+
215
228
do {
216
229
emit ( [ event] + ( try items. map ( { try $0. socketRepresentation ( ) } ) ) , completion: completion)
217
230
} catch {
@@ -242,6 +255,30 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
242
255
/// - parameter items: The items to send with this event. May be left out.
243
256
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
244
257
open func emitWithAck( _ event: String , _ items: SocketData ... ) -> OnAckCallback {
258
+ emitWithAck ( event, with: items)
259
+ }
260
+
261
+ /// Sends a message to the server, requesting an ack.
262
+ ///
263
+ /// **NOTE**: It is up to the server send an ack back, just calling this method does not mean the server will ack.
264
+ /// Check that your server's api will ack the event being sent.
265
+ ///
266
+ /// If an error occurs trying to transform `items` into their socket representation, a `SocketClientEvent.error`
267
+ /// will be emitted. The structure of the error data is `[eventName, items, theError]`
268
+ ///
269
+ /// Example:
270
+ ///
271
+ /// ```swift
272
+ /// socket.emitWithAck("myEvent", 1).timingOut(after: 1) {data in
273
+ /// ...
274
+ /// }
275
+ /// ```
276
+ ///
277
+ /// - parameter event: The event to send.
278
+ /// - parameter items: The items to send with this event. May be left out.
279
+ /// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
280
+ open func emitWithAck( _ event: String , with items: [ SocketData ] ) -> OnAckCallback {
281
+
245
282
do {
246
283
return createOnAck ( [ event] + ( try items. map ( { try $0. socketRepresentation ( ) } ) ) )
247
284
} catch {
0 commit comments