SocketRawView
public final class SocketRawView : NSObject
Class that gives a backwards compatible way to cause an emit not to recursively check for Data objects.
Usage:
socket.rawEmitView.emit("myEvent", myObject)
-
Send an event to the server, with optional data items.
If an error occurs trying to transform
items
into their socket representation, aSocketClientEvent.error
will be emitted. The structure of the error data is[eventName, items, theError]
Declaration
Swift
public func emit(_ event: String, _ items: SocketData...)
Parameters
event
The event to send.
items
The items to send with this event. May be left out.
-
Same as emit, but meant for Objective-C
Declaration
Swift
@objc public func emit(_ event: String, with items: [Any])
Parameters
event
The event to send.
items
The items to send with this event. Send an empty array to send no data.
-
Sends a message to the server, requesting an ack.
NOTE: It is up to the server send an ack back, just calling this method does not mean the server will ack. Check that your server’s api will ack the event being sent.
If an error occurs trying to transform
items
into their socket representation, aSocketClientEvent.error
will be emitted. The structure of the error data is[eventName, items, theError]
Example:
socket.emitWithAck("myEvent", 1).timingOut(after: 1) {data in ... }
Declaration
Swift
public func emitWithAck(_ event: String, _ items: SocketData...) -> OnAckCallback
Parameters
event
The event to send.
items
The items to send with this event. May be left out.
Return Value
An
OnAckCallback
. You must call thetimingOut(after:)
method before the event will be sent. -
Same as emitWithAck, but for Objective-C
NOTE: It is up to the server send an ack back, just calling this method does not mean the server will ack. Check that your server’s api will ack the event being sent.
Example:
socket.emitWithAck("myEvent", with: [1]).timingOut(after: 1) {data in ... }
Declaration
Swift
@objc public func emitWithAck(_ event: String, with items: [Any]) -> OnAckCallback
Parameters
event
The event to send.
items
The items to send with this event. Use
[]
to send nothing.Return Value
An
OnAckCallback
. You must call thetimingOut(after:)
method before the event will be sent.