Skip to content

Commit 61d0a41

Browse files
docs: add compatibility table
1 parent 07f2d08 commit 61d0a41

File tree

3 files changed

+81
-1
lines changed

3 files changed

+81
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ socket.connect()
3232
```
3333

3434
## Features
35-
- Supports socket.io 2.0+/3.0+.
35+
- Supports Socket.IO server 2.0+/3.0+/4.0+ (see the [compatibility table](https://nuclearace.github.io/Socket.IO-Client-Swift/Compatibility.html))
3636
- Supports Binary
3737
- Supports Polling and WebSockets
3838
- Supports TLS/SSL

Usage Docs/15to16.md

+19
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,23 @@ is socket.io 2, you must send `.version(.two)` as an option to the manager.
1313
SocketManager(socketURL: URL(string:"http://localhost:8087/")!, config: [.version(.two)])
1414
```
1515

16+
## How to upgrade
1617

18+
- first, upgrade the Socket.IO server to v4 with the compatibility mode enabled (`allowEIO3: true`)
19+
- then, upgrade the clients to v16
20+
- finally, once all clients have upgraded, disable the compatibility mode
21+
22+
You can check the version of the connection on the server side with:
23+
24+
```js
25+
io.on("connection", (socket) => {
26+
// either 3 for the 3rd revision of the protocol (Socket.IO v2) or 4 for the 4th revision (Socket.IO v3/v4)
27+
const version = socket.conn.protocol;
28+
});
29+
```
30+
31+
See also:
32+
33+
- [Compatibility table](https://nuclearace.github.io/Socket.IO-Client-Swift/Compatibility.html)
34+
- Migrating from 2.x to 3.0: https://socket.io/docs/v4/migrating-from-2-x-to-3-0/
35+
- Migrating from 3.x to 4.0: https://socket.io/docs/v4/migrating-from-3-x-to-4-0/

Usage Docs/Compatibility.md

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
Here is the compatibility table with the Node.js server:
2+
3+
<table>
4+
<tr>
5+
<th rowspan="2">Swift Client version</th>
6+
<th colspan="3">Socket.IO server version</th>
7+
</tr>
8+
<tr>
9+
<td align="center">2.x</td>
10+
<td align="center">3.x</td>
11+
<td align="center">4.x</td>
12+
</tr>
13+
<tr>
14+
<td align="center">v15.x</td>
15+
<td align="center"><b>YES</b></td>
16+
<td align="center"><b>YES</b><sup>1</sup></td>
17+
<td align="center"><b>YES</b><sup>2</sup></td>
18+
</tr>
19+
<tr>
20+
<td align="center">v16.x</td>
21+
<td align="center"><b>YES</b><sup>3</sup></td>
22+
<td align="center"><b>YES</b></td>
23+
<td align="center"><b>YES</b></td>
24+
</tr>
25+
</table>
26+
27+
[1] Yes, with <code><a href="https://socket.io/docs/v4/server-initialization/#allowEIO3">allowEIO3: true</a></code> (server) and `.connectParams(["EIO": "3"])` (client):
28+
29+
*Server*
30+
31+
```js
32+
const { createServer } = require("http");
33+
const { Server } = require("socket.io");
34+
35+
const httpServer = createServer();
36+
const io = new Server(httpServer, {
37+
allowEIO3: true
38+
});
39+
40+
httpServer.listen(8080);
41+
```
42+
43+
*Client*
44+
45+
```swift
46+
SocketManager(socketURL: URL(string:"http://localhost:8080/")!, config: [.connectParams(["EIO": "3"])])
47+
```
48+
49+
[2] Yes, <code><a href="https://socket.io/docs/v4/server-initialization/#allowEIO3">allowEIO3: true</a></code> (server)
50+
51+
[3] Yes, with `.version(.two)` (client):
52+
53+
```swift
54+
SocketManager(socketURL: URL(string:"http://localhost:8080/")!, config: [.version(.two)])
55+
```
56+
57+
See also:
58+
59+
- Migrating from 2.x to 3.0: https://socket.io/docs/v4/migrating-from-2-x-to-3-0/
60+
- Migrating from 3.x to 4.0: https://socket.io/docs/v4/migrating-from-3-x-to-4-0/
61+
- Socket.IO protocol: https://github.com/socketio/socket.io-protocol

0 commit comments

Comments
 (0)