Skip to content

Commit a7c90cd

Browse files
committed
update docs
1 parent 74fa414 commit a7c90cd

File tree

2 files changed

+18
-121
lines changed

2 files changed

+18
-121
lines changed

README.md

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ import PackageDescription
8282
let package = Package(
8383
name: "YourSocketIOProject",
8484
dependencies: [
85-
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 8)
85+
.Package(url: "https://github.com/socketio/socket.io-client-swift", majorVersion: 9)
8686
]
8787
)
8888
```
@@ -92,7 +92,7 @@ Then import `import SocketIO`.
9292
### Carthage
9393
Add this line to your `Cartfile`:
9494
```
95-
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
9696
```
9797

9898
Run `carthage update --platform ios,macosx`.
@@ -104,7 +104,7 @@ Create `Podfile` and add `pod 'Socket.IO-Client-Swift'`:
104104
use_frameworks!
105105

106106
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
108108
end
109109
```
110110

@@ -132,68 +132,17 @@ Objective-C:
132132
Add this line to your `Seedfile`:
133133

134134
```
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
136136
```
137137

138138
Run `seed install`.
139139

140140

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.
141+
# [Docs](https://nuclearace.github.io/Socket.IO-Client-Swift/index.html)
145142

146-
`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-
case connectParams([String: AnyObject]) // Dictionary whose contents will be passed with the connection.
153-
case cookies([NSHTTPCookie]) // An array of NSHTTPCookies. Passed during the handshake. Default is nil.
154-
case doubleEncodeUTF8(Bool) // Whether or not to double encode utf8. If using the node based server this should be true. Default is true.
155-
case extraHeaders([String: String]) // Adds custom headers to the initial request. Default is nil.
156-
case forcePolling(Bool) // `true` forces the client to use xhr-polling. Default is `false`
157-
case forceNew(Bool) // Will a create a new engine for each connect. Useful if you find a bug in the engine related to reconnects
158-
case forceWebsockets(Bool) // `true` forces the client to use WebSockets. Default is `false`
159-
case handleQueue(dispatch_queue_t) // The dispatch queue that handlers are run on. Default is the main queue.
160-
case log(Bool) // If `true` socket will log debug messages. Default is false.
161-
case logger(SocketLogger) // Custom logger that conforms to SocketLogger. Will use the default logging otherwise.
162-
case nsp(String) // The namespace to connect to. Must begin with /. Default is `/`
163-
case path(String) // If the server uses a custom path. ex: `"/swift/"`. Default is `""`
164-
case reconnects(Bool) // Whether to reconnect on server lose. Default is `true`
165-
case reconnectAttempts(Int) // How many times to reconnect. Default is `-1` (infinite tries)
166-
case reconnectWait(Int) // Amount of time to wait between reconnects. Default is `10`
167-
case sessionDelegate(NSURLSessionDelegate) // Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.
168-
case secure(Bool) // If the connection should use TLS. Default is false.
169-
case security(SSLSecurity) // Allows you to set which certs are valid. Useful for SSL pinning.
170-
case selfSigned(Bool) // Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs.
171-
case voipEnabled(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.
143+
- [Client](https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketIOClient.html)
144+
- [Engine](https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketEngine.html)
145+
- [Options](https://nuclearace.github.io/Socket.IO-Client-Swift/Enums/SocketIOClientOption.html)
197146

198147
## Detailed Example
199148
A more detailed example can be found [here](https://github.com/nuclearace/socket.io-client-swift-example)

docs/index.html

Lines changed: 10 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ <h3 id='swift-package-manager' class='heading'>Swift Package Manager</h3>
253253
<span class="k">let</span> <span class="nv">package</span> <span class="o">=</span> <span class="kt">Package</span><span class="p">(</span>
254254
<span class="nv">name</span><span class="p">:</span> <span class="s">"YourSocketIOProject"</span><span class="p">,</span>
255255
<span class="nv">dependencies</span><span class="p">:</span> <span class="p">[</span>
256-
<span class="o">.</span><span class="kt">Package</span><span class="p">(</span><span class="nv">url</span><span class="p">:</span> <span class="s">"https://github.com/socketio/socket.io-client-swift"</span><span class="p">,</span> <span class="nv">majorVersion</span><span class="p">:</span> <span class="mi">8</span><span class="p">)</span>
256+
<span class="o">.</span><span class="kt">Package</span><span class="p">(</span><span class="nv">url</span><span class="p">:</span> <span class="s">"https://github.com/socketio/socket.io-client-swift"</span><span class="p">,</span> <span class="nv">majorVersion</span><span class="p">:</span> <span class="mi">9</span><span class="p">)</span>
257257
<span class="p">]</span>
258258
<span class="p">)</span>
259259
</code></pre>
@@ -262,7 +262,7 @@ <h3 id='swift-package-manager' class='heading'>Swift Package Manager</h3>
262262
<h3 id='carthage' class='heading'>Carthage</h3>
263263

264264
<p>Add this line to your <code>Cartfile</code>:</p>
265-
<pre class="highlight plaintext"><code>github "socketio/socket.io-client-swift" ~&gt; 8.3.3 # Or latest version
265+
<pre class="highlight plaintext"><code>github "socketio/socket.io-client-swift" ~&gt; 9.0.0 # Or latest version
266266
</code></pre>
267267

268268
<p>Run <code>carthage update --platform ios,macosx</code>.</p>
@@ -272,7 +272,7 @@ <h3 id='cocoapods-1-0-0-or-later' class='heading'>CocoaPods 1.0.0 or later</h3>
272272
<pre class="highlight ruby"><code><span class="n">use_frameworks!</span>
273273

274274
<span class="n">target</span> <span class="s1">'YourApp'</span> <span class="k">do</span>
275-
<span class="n">pod</span> <span class="s1">'Socket.IO-Client-Swift'</span><span class="p">,</span> <span class="s1">'~&gt; 8.3.3'</span> <span class="c1"># Or latest version</span>
275+
<span class="n">pod</span> <span class="s1">'Socket.IO-Client-Swift'</span><span class="p">,</span> <span class="s1">'~&gt; 9.0.0'</span> <span class="c1"># Or latest version</span>
276276
<span class="k">end</span>
277277
</code></pre>
278278

@@ -292,69 +292,17 @@ <h3 id='cocoapods-1-0-0-or-later' class='heading'>CocoaPods 1.0.0 or later</h3>
292292
<h3 id='cocoaseeds' class='heading'>CocoaSeeds</h3>
293293

294294
<p>Add this line to your <code>Seedfile</code>:</p>
295-
<pre class="highlight plaintext"><code>github "socketio/socket.io-client-swift", "v8.3.3", :files =&gt; "Source/*.swift" # Or latest version
295+
<pre class="highlight plaintext"><code>github "socketio/socket.io-client-swift", "v9.0.0", :files =&gt; "Source/*.swift" # Or latest version
296296
</code></pre>
297297

298298
<p>Run <code>seed install</code>.</p>
299-
<h1 id='api' class='heading'>API</h1>
300-
<h2 id='constructors' class='heading'>Constructors</h2>
301-
302-
<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-
<h3 id='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-
<pre class="highlight swift"><code><span class="k">case</span> <span class="nf">connectParams</span><span class="p">([</span><span class="kt">String</span><span class="p">:</span> <span class="kt">AnyObject</span><span class="p">])</span> <span class="c1">// Dictionary whose contents will be passed with the connection.</span>
309-
<span class="k">case</span> <span class="nf">cookies</span><span class="p">([</span><span class="kt">NSHTTPCookie</span><span class="p">])</span> <span class="c1">// An array of NSHTTPCookies. Passed during the handshake. Default is nil.</span>
310-
<span class="k">case</span> <span class="nf">doubleEncodeUTF8</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// Whether or not to double encode utf8. If using the node based server this should be true. Default is true.</span>
311-
<span class="k">case</span> <span class="nf">extraHeaders</span><span class="p">([</span><span class="kt">String</span><span class="p">:</span> <span class="kt">String</span><span class="p">])</span> <span class="c1">// Adds custom headers to the initial request. Default is nil.</span>
312-
<span class="k">case</span> <span class="nf">forcePolling</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// `true` forces the client to use xhr-polling. Default is `false`</span>
313-
<span class="k">case</span> <span class="nf">forceNew</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// Will a create a new engine for each connect. Useful if you find a bug in the engine related to reconnects</span>
314-
<span class="k">case</span> <span class="nf">forceWebsockets</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// `true` forces the client to use WebSockets. Default is `false`</span>
315-
<span class="k">case</span> <span class="nf">handleQueue</span><span class="p">(</span><span class="n">dispatch_queue_t</span><span class="p">)</span> <span class="c1">// The dispatch queue that handlers are run on. Default is the main queue.</span>
316-
<span class="k">case</span> <span class="nf">log</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// If `true` socket will log debug messages. Default is false.</span>
317-
<span class="k">case</span> <span class="nf">logger</span><span class="p">(</span><span class="kt">SocketLogger</span><span class="p">)</span> <span class="c1">// Custom logger that conforms to SocketLogger. Will use the default logging otherwise.</span>
318-
<span class="k">case</span> <span class="nf">nsp</span><span class="p">(</span><span class="kt">String</span><span class="p">)</span> <span class="c1">// The namespace to connect to. Must begin with /. Default is `/`</span>
319-
<span class="k">case</span> <span class="nf">path</span><span class="p">(</span><span class="kt">String</span><span class="p">)</span> <span class="c1">// If the server uses a custom path. ex: `"/swift/"`. Default is `""`</span>
320-
<span class="k">case</span> <span class="nf">reconnects</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// Whether to reconnect on server lose. Default is `true`</span>
321-
<span class="k">case</span> <span class="nf">reconnectAttempts</span><span class="p">(</span><span class="kt">Int</span><span class="p">)</span> <span class="c1">// How many times to reconnect. Default is `-1` (infinite tries)</span>
322-
<span class="k">case</span> <span class="nf">reconnectWait</span><span class="p">(</span><span class="kt">Int</span><span class="p">)</span> <span class="c1">// Amount of time to wait between reconnects. Default is `10`</span>
323-
<span class="k">case</span> <span class="nf">sessionDelegate</span><span class="p">(</span><span class="kt">NSURLSessionDelegate</span><span class="p">)</span> <span class="c1">// Sets an NSURLSessionDelegate for the underlying engine. Useful if you need to handle self-signed certs. Default is nil.</span>
324-
<span class="k">case</span> <span class="nf">secure</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// If the connection should use TLS. Default is false.</span>
325-
<span class="k">case</span> <span class="nf">security</span><span class="p">(</span><span class="kt">SSLSecurity</span><span class="p">)</span> <span class="c1">// Allows you to set which certs are valid. Useful for SSL pinning.</span>
326-
<span class="k">case</span> <span class="nf">selfSigned</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="c1">// Sets WebSocket.selfSignedSSL. Use this if you're using self-signed certs.</span>
327-
<span class="k">case</span> <span class="nf">voipEnabled</span><span class="p">(</span><span class="kt">Bool</span><span class="p">)</span> <span class="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-
<h3 id='methods' class='heading'>Methods</h3>
330-
331-
<ol>
332-
<li><code>on(_ event: String, callback: NormalCallback) -&gt; 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) -&gt; 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?)) -&gt; 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...) -&gt; 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]) -&gt; 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: (() -&gt; Void)?)</code> - Connect to the server. If it isn&rsquo;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&rsquo;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>
348-
</ol>
349-
<h3 id='client-events' class='heading'>Client Events</h3>
299+
<h1 id='a-href-https-nuclearace-github-io-socket-io-client-swift-index-html-docs-a' class='heading'><a href="https://nuclearace.github.io/Socket.IO-Client-Swift/index.html">Docs</a></h1>
350300

351-
<ol>
352-
<li><code>connect</code> - Emitted when on a successful connection.</li>
353-
<li><code>disconnect</code> - Emitted when the connection is closed.</li>
354-
<li><code>error</code> - Emitted on an error.</li>
355-
<li><code>reconnect</code> - Emitted when the connection is starting to reconnect.</li>
356-
<li><code>reconnectAttempt</code> - Emitted when attempting to reconnect.</li>
357-
</ol>
301+
<ul>
302+
<li><a href="https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketIOClient.html">Client</a></li>
303+
<li><a href="https://nuclearace.github.io/Socket.IO-Client-Swift/Classes/SocketEngine.html">Engine</a></li>
304+
<li><a href="https://nuclearace.github.io/Socket.IO-Client-Swift/Enums/SocketIOClientOption.html">Options</a></li>
305+
</ul>
358306
<h2 id='detailed-example' class='heading'>Detailed Example</h2>
359307

360308
<p>A more detailed example can be found <a href="https://github.com/nuclearace/socket.io-client-swift-example">here</a></p>

0 commit comments

Comments
 (0)