You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
github "socketio/socket.io-client-swift" ~> 8.3.3 # Or latest version
95
+
github "socketio/socket.io-client-swift" ~> 9.0.0 # Or latest version
96
96
```
97
97
98
98
Run `carthage update --platform ios,macosx`.
@@ -104,7 +104,7 @@ Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`:
104
104
use_frameworks!
105
105
106
106
target 'YourApp'do
107
-
pod 'Socket.IO-Client-Swift', '~> 8.3.3'# Or latest version
107
+
pod 'Socket.IO-Client-Swift', '~> 9.0.0'# Or latest version
108
108
end
109
109
```
110
110
@@ -132,68 +132,17 @@ Objective-C:
132
132
Add this line to your `Seedfile`:
133
133
134
134
```
135
-
github "socketio/socket.io-client-swift", "v8.3.3", :files => "Source/*.swift" # Or latest version
135
+
github "socketio/socket.io-client-swift", "v9.0.0", :files => "Source/*.swift" # Or latest version
136
136
```
137
137
138
138
Run `seed install`.
139
139
140
140
141
-
# API
142
-
Constructors
143
-
-----------
144
-
`init(var socketURL: NSURL, config: SocketIOClientConfiguration = [])` - Creates a new SocketIOClient. If your socket.io server is secure, you need to specify `https` in your socketURL.
`convenience init(socketURL: NSURL, options: NSDictionary?)` - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys.
147
-
148
-
### Options
149
-
All options are a case of SocketIOClientOption. To get the Objective-C Option, convert the name to lowerCamelCase.
150
-
151
-
```swift
152
-
caseconnectParams([String:AnyObject]) // Dictionary whose contents will be passed with the connection.
153
-
casecookies([NSHTTPCookie]) // An array of NSHTTPCookies. Passed during the handshake. Default is nil.
154
-
casedoubleEncodeUTF8(Bool) // Whether or not to double encode utf8. If using the node based server this should be true. Default is true.
155
-
caseextraHeaders([String:String]) // Adds custom headers to the initial request. Default is nil.
156
-
caseforcePolling(Bool) // `true` forces the client to use xhr-polling. Default is `false`
157
-
caseforceNew(Bool) // Will a create a new engine for each connect. Useful if you find a bug in the engine related to reconnects
158
-
caseforceWebsockets(Bool) // `true` forces the client to use WebSockets. Default is `false`
159
-
casehandleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue.
160
-
caselog(Bool) // If `true` socket will log debug messages. Default is false.
161
-
caselogger(SocketLogger) // Custom logger that conforms to SocketLogger. Will use the default logging otherwise.
162
-
casensp(String) // The namespace to connect to. Must begin with /. Default is `/`
163
-
casepath(String) // If the server uses a custom path. ex: `"/swift/"`. Default is `""`
164
-
casereconnects(Bool) // Whether to reconnect on server lose. Default is `true`
165
-
casereconnectAttempts(Int) // How many times to reconnect. Default is `-1` (infinite tries)
166
-
casereconnectWait(Int) // Amount of time to wait between reconnects. Default is `10`
167
-
casesessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
168
-
casesecure(Bool) // If the connection should use TLS. Default is false.
169
-
casesecurity(SSLSecurity) // Allows you to set which certs are valid. Useful for SSL pinning.
170
-
caseselfSigned(Bool) // Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs.
171
-
casevoipEnabled(Bool) // Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false
172
-
```
173
-
### Methods
174
-
1.`on(_ event: String, callback: NormalCallback) -> NSUUID` - Adds a handler for an event. Items are passed by an array. `ack` can be used to send an ack when one is requested. See example. Returns a unique id for the handler.
175
-
2.`once(_ event: String, callback: NormalCallback) -> NSUUID` - Adds a handler that will only be executed once. Returns a unique id for the handler.
176
-
3.`onAny(callback:((event: String, items: AnyObject?)) -> Void)` - Adds a handler for all events. It will be called on any received event.
177
-
4.`emit(_ event: String, _ items: AnyObject...)` - Sends a message. Can send multiple items.
178
-
5.`emit(_ event: String, withItems items: [AnyObject])` - `emit` for Objective-C
179
-
6.`emitWithAck(_ event: String, _ items: AnyObject...) -> OnAckCallback` - Sends a message that requests an acknowledgement from the server. Returns an object which you can use to add a handler. See example. Note: The message is not sent until you call timingOut(after:) on the returned object.
180
-
7.`emitWithAck(_ event: String, withItems items: [AnyObject]) -> OnAckCallback` - `emitWithAck` for Objective-C. Note: The message is not sent until you call timingOutAfter on the returned object.
181
-
8.`connect()` - Establishes a connection to the server. A "connect" event is fired upon successful connection.
182
-
9.`connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)` - Connect to the server. If it isn't connected after timeoutAfter seconds, the handler is called.
183
-
10.`disconnect()` - Closes the socket. Reopening a disconnected socket is not fully tested.
184
-
11.`reconnect()` - Causes the client to reconnect to the server.
185
-
12.`joinNamespace(_ namespace: String)` - Causes the client to join namespace. Shouldn't need to be called unless you change namespaces manually.
186
-
13.`leaveNamespace()` - Causes the client to leave the nsp and go back to /
187
-
14.`off(_ event: String)` - Removes all event handlers for event.
188
-
15.`off(id id: NSUUID)` - Removes the event that corresponds to id.
189
-
16.`removeAllHandlers()` - Removes all handlers.
190
-
191
-
### Client Events
192
-
1.`connect` - Emitted when on a successful connection.
193
-
2.`disconnect` - Emitted when the connection is closed.
194
-
3.`error` - Emitted on an error.
195
-
4.`reconnect` - Emitted when the connection is starting to reconnect.
196
-
5.`reconnectAttempt` - Emitted when attempting to reconnect.
<spanclass="n">pod</span><spanclass="s1">'Socket.IO-Client-Swift'</span><spanclass="p">,</span><spanclass="s1">'~> 8.3.3'</span><spanclass="c1"># Or latest version</span>
275
+
<spanclass="n">pod</span><spanclass="s1">'Socket.IO-Client-Swift'</span><spanclass="p">,</span><spanclass="s1">'~> 9.0.0'</span><spanclass="c1"># Or latest version</span>
276
276
<spanclass="k">end</span>
277
277
</code></pre>
278
278
@@ -292,69 +292,17 @@ <h3 id='cocoapods-1-0-0-or-later' class='heading'>CocoaPods 1.0.0 or later</h3>
<p><code>init(var socketURL: NSURL, config: SocketIOClientConfiguration = [])</code> - Creates a new SocketIOClient. If your socket.io server is secure, you need to specify <code>https</code> in your socketURL.</p>
303
-
304
-
<p><code>convenience init(socketURL: NSURL, options: NSDictionary?)</code> - Same as above, but meant for Objective-C. See Options on how convert between SocketIOClientOptions and dictionary keys.</p>
305
-
<h3id='options' class='heading'>Options</h3>
306
-
307
-
<p>All options are a case of SocketIOClientOption. To get the Objective-C Option, convert the name to lowerCamelCase.</p>
308
-
<preclass="highlight swift"><code><spanclass="k">case</span><spanclass="nf">connectParams</span><spanclass="p">([</span><spanclass="kt">String</span><spanclass="p">:</span><spanclass="kt">AnyObject</span><spanclass="p">])</span><spanclass="c1">// Dictionary whose contents will be passed with the connection.</span>
309
-
<spanclass="k">case</span><spanclass="nf">cookies</span><spanclass="p">([</span><spanclass="kt">NSHTTPCookie</span><spanclass="p">])</span><spanclass="c1">// An array of NSHTTPCookies. Passed during the handshake. Default is nil.</span>
310
-
<spanclass="k">case</span><spanclass="nf">doubleEncodeUTF8</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// Whether or not to double encode utf8. If using the node based server this should be true. Default is true.</span>
311
-
<spanclass="k">case</span><spanclass="nf">extraHeaders</span><spanclass="p">([</span><spanclass="kt">String</span><spanclass="p">:</span><spanclass="kt">String</span><spanclass="p">])</span><spanclass="c1">// Adds custom headers to the initial request. Default is nil.</span>
312
-
<spanclass="k">case</span><spanclass="nf">forcePolling</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// `true` forces the client to use xhr-polling. Default is `false`</span>
313
-
<spanclass="k">case</span><spanclass="nf">forceNew</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// Will a create a new engine for each connect. Useful if you find a bug in the engine related to reconnects</span>
314
-
<spanclass="k">case</span><spanclass="nf">forceWebsockets</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// `true` forces the client to use WebSockets. Default is `false`</span>
315
-
<spanclass="k">case</span><spanclass="nf">handleQueue</span><spanclass="p">(</span><spanclass="n">dispatch_queue_t</span><spanclass="p">)</span><spanclass="c1">// The dispatch queue that handlers are run on. Default is the main queue.</span>
316
-
<spanclass="k">case</span><spanclass="nf">log</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// If `true` socket will log debug messages. Default is false.</span>
317
-
<spanclass="k">case</span><spanclass="nf">logger</span><spanclass="p">(</span><spanclass="kt">SocketLogger</span><spanclass="p">)</span><spanclass="c1">// Custom logger that conforms to SocketLogger. Will use the default logging otherwise.</span>
318
-
<spanclass="k">case</span><spanclass="nf">nsp</span><spanclass="p">(</span><spanclass="kt">String</span><spanclass="p">)</span><spanclass="c1">// The namespace to connect to. Must begin with /. Default is `/`</span>
319
-
<spanclass="k">case</span><spanclass="nf">path</span><spanclass="p">(</span><spanclass="kt">String</span><spanclass="p">)</span><spanclass="c1">// If the server uses a custom path. ex: `"/swift/"`. Default is `""`</span>
320
-
<spanclass="k">case</span><spanclass="nf">reconnects</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// Whether to reconnect on server lose. Default is `true`</span>
321
-
<spanclass="k">case</span><spanclass="nf">reconnectAttempts</span><spanclass="p">(</span><spanclass="kt">Int</span><spanclass="p">)</span><spanclass="c1">// How many times to reconnect. Default is `-1` (infinite tries)</span>
322
-
<spanclass="k">case</span><spanclass="nf">reconnectWait</span><spanclass="p">(</span><spanclass="kt">Int</span><spanclass="p">)</span><spanclass="c1">// Amount of time to wait between reconnects. Default is `10`</span>
323
-
<spanclass="k">case</span><spanclass="nf">sessionDelegate</span><spanclass="p">(</span><spanclass="kt">NSURLSessionDelegate</span><spanclass="p">)</span><spanclass="c1">// Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.</span>
324
-
<spanclass="k">case</span><spanclass="nf">secure</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// If the connection should use TLS. Default is false.</span>
325
-
<spanclass="k">case</span><spanclass="nf">security</span><spanclass="p">(</span><spanclass="kt">SSLSecurity</span><spanclass="p">)</span><spanclass="c1">// Allows you to set which certs are valid. Useful for SSL pinning.</span>
326
-
<spanclass="k">case</span><spanclass="nf">selfSigned</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs.</span>
327
-
<spanclass="k">case</span><spanclass="nf">voipEnabled</span><spanclass="p">(</span><spanclass="kt">Bool</span><spanclass="p">)</span><spanclass="c1">// Only use this option if you're using the client with VoIP services. Changes the way the WebSocket is created. Default is false</span>
328
-
</code></pre>
329
-
<h3id='methods' class='heading'>Methods</h3>
330
-
331
-
<ol>
332
-
<li><code>on(_ event: String, callback: NormalCallback) -> NSUUID</code> - Adds a handler for an event. Items are passed by an array. <code>ack</code> can be used to send an ack when one is requested. See example. Returns a unique id for the handler.</li>
333
-
<li><code>once(_ event: String, callback: NormalCallback) -> NSUUID</code> - Adds a handler that will only be executed once. Returns a unique id for the handler.</li>
334
-
<li><code>onAny(callback:((event: String, items: AnyObject?)) -> Void)</code> - Adds a handler for all events. It will be called on any received event.</li>
335
-
<li><code>emit(_ event: String, _ items: AnyObject...)</code> - Sends a message. Can send multiple items.</li>
336
-
<li><code>emit(_ event: String, withItems items: [AnyObject])</code> - <code>emit</code> for Objective-C</li>
337
-
<li><code>emitWithAck(_ event: String, _ items: AnyObject...) -> OnAckCallback</code> - Sends a message that requests an acknowledgement from the server. Returns an object which you can use to add a handler. See example. Note: The message is not sent until you call timingOut(after:) on the returned object.</li>
338
-
<li><code>emitWithAck(_ event: String, withItems items: [AnyObject]) -> OnAckCallback</code> - <code>emitWithAck</code> for Objective-C. Note: The message is not sent until you call timingOutAfter on the returned object.</li>
339
-
<li><code>connect()</code> - Establishes a connection to the server. A <q>connect</q> event is fired upon successful connection.</li>
340
-
<li><code>connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?)</code> - Connect to the server. If it isn’t connected after timeoutAfter seconds, the handler is called.</li>
341
-
<li><code>disconnect()</code> - Closes the socket. Reopening a disconnected socket is not fully tested.</li>
342
-
<li><code>reconnect()</code> - Causes the client to reconnect to the server.</li>
343
-
<li><code>joinNamespace(_ namespace: String)</code> - Causes the client to join namespace. Shouldn’t need to be called unless you change namespaces manually.</li>
344
-
<li><code>leaveNamespace()</code> - Causes the client to leave the nsp and go back to /</li>
345
-
<li><code>off(_ event: String)</code> - Removes all event handlers for event.</li>
346
-
<li><code>off(id id: NSUUID)</code> - Removes the event that corresponds to id.</li>
347
-
<li><code>removeAllHandlers()</code> - Removes all handlers.</li>
0 commit comments