Merge branch 'development'
* development: handle version in keyValueToSocketIOClientOption Updated methods signature Added client emit methods with array parameters
This commit is contained in:
commit
af5ce97b75
@ -1,7 +1,7 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "Socket.IO-Client-Swift"
|
s.name = "Socket.IO-Client-Swift"
|
||||||
s.module_name = "SocketIO"
|
s.module_name = "SocketIO"
|
||||||
s.version = "16.0.0"
|
s.version = "16.0.1"
|
||||||
s.summary = "Socket.IO-client for iOS and OS X"
|
s.summary = "Socket.IO-client for iOS and OS X"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
Socket.IO-client for iOS and OS X.
|
Socket.IO-client for iOS and OS X.
|
||||||
@ -18,7 +18,7 @@ Pod::Spec.new do |s|
|
|||||||
s.requires_arc = true
|
s.requires_arc = true
|
||||||
s.source = {
|
s.source = {
|
||||||
:git => "https://github.com/socketio/socket.io-client-swift.git",
|
:git => "https://github.com/socketio/socket.io-client-swift.git",
|
||||||
:tag => 'v16.0.0',
|
:tag => 'v16.0.1',
|
||||||
:submodules => true
|
:submodules => true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -212,6 +212,19 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
|
|||||||
/// - parameter items: The items to send with this event. May be left out.
|
/// - parameter items: The items to send with this event. May be left out.
|
||||||
/// - parameter completion: Callback called on transport write completion.
|
/// - parameter completion: Callback called on transport write completion.
|
||||||
open func emit(_ event: String, _ items: SocketData..., completion: (() -> ())? = nil) {
|
open func emit(_ event: String, _ items: SocketData..., completion: (() -> ())? = nil) {
|
||||||
|
emit(event, with: items, completion: completion)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Send an event to the server, with optional data items and optional write completion handler.
|
||||||
|
///
|
||||||
|
/// If an error occurs trying to transform `items` into their socket representation, a `SocketClientEvent.error`
|
||||||
|
/// will be emitted. The structure of the error data is `[eventName, items, theError]`
|
||||||
|
///
|
||||||
|
/// - parameter event: The event to send.
|
||||||
|
/// - parameter items: The items to send with this event. May be left out.
|
||||||
|
/// - parameter completion: Callback called on transport write completion.
|
||||||
|
open func emit(_ event: String, with items: [SocketData], completion: (() -> ())?) {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
emit([event] + (try items.map({ try $0.socketRepresentation() })), completion: completion)
|
emit([event] + (try items.map({ try $0.socketRepresentation() })), completion: completion)
|
||||||
} catch {
|
} catch {
|
||||||
@ -242,6 +255,30 @@ open class SocketIOClient: NSObject, SocketIOClientSpec {
|
|||||||
/// - parameter items: The items to send with this event. May be left out.
|
/// - parameter items: The items to send with this event. May be left out.
|
||||||
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
|
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
|
||||||
open func emitWithAck(_ event: String, _ items: SocketData...) -> OnAckCallback {
|
open func emitWithAck(_ event: String, _ items: SocketData...) -> OnAckCallback {
|
||||||
|
emitWithAck(event, with: items)
|
||||||
|
}
|
||||||
|
|
||||||
|
/// 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, a `SocketClientEvent.error`
|
||||||
|
/// will be emitted. The structure of the error data is `[eventName, items, theError]`
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
///
|
||||||
|
/// ```swift
|
||||||
|
/// socket.emitWithAck("myEvent", 1).timingOut(after: 1) {data in
|
||||||
|
/// ...
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// - parameter event: The event to send.
|
||||||
|
/// - parameter items: The items to send with this event. May be left out.
|
||||||
|
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
|
||||||
|
open func emitWithAck(_ event: String, with items: [SocketData]) -> OnAckCallback {
|
||||||
|
|
||||||
do {
|
do {
|
||||||
return createOnAck([event] + (try items.map({ try $0.socketRepresentation() })))
|
return createOnAck([event] + (try items.map({ try $0.socketRepresentation() })))
|
||||||
} catch {
|
} catch {
|
||||||
|
|||||||
@ -108,6 +108,16 @@ public protocol SocketIOClientSpec : AnyObject {
|
|||||||
/// - parameter completion: Callback called on transport write completion.
|
/// - parameter completion: Callback called on transport write completion.
|
||||||
func emit(_ event: String, _ items: SocketData..., completion: (() -> ())?)
|
func emit(_ event: String, _ items: SocketData..., completion: (() -> ())?)
|
||||||
|
|
||||||
|
/// Send an event to the server, with optional data items and optional write completion handler.
|
||||||
|
///
|
||||||
|
/// If an error occurs trying to transform `items` into their socket representation, a `SocketClientEvent.error`
|
||||||
|
/// will be emitted. The structure of the error data is `[eventName, items, theError]`
|
||||||
|
///
|
||||||
|
/// - parameter event: The event to send.
|
||||||
|
/// - parameter items: The items to send with this event. May be left out.
|
||||||
|
/// - parameter completion: Callback called on transport write completion.
|
||||||
|
func emit(_ event: String, with items: [SocketData], completion: (() -> ())?)
|
||||||
|
|
||||||
/// Call when you wish to tell the server that you've received the event for `ack`.
|
/// Call when you wish to tell the server that you've received the event for `ack`.
|
||||||
///
|
///
|
||||||
/// - parameter ack: The ack number.
|
/// - parameter ack: The ack number.
|
||||||
@ -135,6 +145,27 @@ public protocol SocketIOClientSpec : AnyObject {
|
|||||||
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
|
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
|
||||||
func emitWithAck(_ event: String, _ items: SocketData...) -> OnAckCallback
|
func emitWithAck(_ event: String, _ items: SocketData...) -> OnAckCallback
|
||||||
|
|
||||||
|
/// 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, a `SocketClientEvent.error`
|
||||||
|
/// will be emitted. The structure of the error data is `[eventName, items, theError]`
|
||||||
|
///
|
||||||
|
/// Example:
|
||||||
|
///
|
||||||
|
/// ```swift
|
||||||
|
/// socket.emitWithAck("myEvent", 1).timingOut(after: 1) {data in
|
||||||
|
/// ...
|
||||||
|
/// }
|
||||||
|
/// ```
|
||||||
|
///
|
||||||
|
/// - parameter event: The event to send.
|
||||||
|
/// - parameter items: The items to send with this event. May be left out.
|
||||||
|
/// - returns: An `OnAckCallback`. You must call the `timingOut(after:)` method before the event will be sent.
|
||||||
|
func emitWithAck(_ event: String, with items: [SocketData]) -> OnAckCallback
|
||||||
|
|
||||||
/// Called when socket.io has acked one of our emits. Causes the corresponding ack callback to be called.
|
/// Called when socket.io has acked one of our emits. Causes the corresponding ack callback to be called.
|
||||||
///
|
///
|
||||||
/// - parameter ack: The number for this ack.
|
/// - parameter ack: The number for this ack.
|
||||||
|
|||||||
@ -87,7 +87,9 @@ extension Dictionary where Key == String, Value == Any {
|
|||||||
return compress ? .compress : nil
|
return compress ? .compress : nil
|
||||||
case let ("enableSOCKSProxy", enable as Bool):
|
case let ("enableSOCKSProxy", enable as Bool):
|
||||||
return .enableSOCKSProxy(enable)
|
return .enableSOCKSProxy(enable)
|
||||||
default:
|
case let ("version", version as Int):
|
||||||
|
return .version(SocketIOVersion(rawValue: version) ?? .three)
|
||||||
|
case _:
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user