Skip to content

Commit b686b17

Browse files
authored
Merge pull request #1385 from NachoSoto/master
Added support for Mac Catalyst
2 parents af5ce97 + c6d2824 commit b686b17

File tree

7 files changed

+136
-77
lines changed

7 files changed

+136
-77
lines changed

README.md

Lines changed: 1 addition & 1 deletion
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

Socket.IO-Client-Swift.xcodeproj/project.pbxproj

Lines changed: 51 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 52;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -19,9 +19,9 @@
1919
1C686BE71F869AFD007D8627 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C686BD71F869AF1007D8627 /* SocketParserTest.swift */; };
2020
1C686BE81F869AFD007D8627 /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1C686BD81F869AF1007D8627 /* SocketNamespacePacketTest.swift */; };
2121
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
22+
579C7D4C2731B487009F8A2F /* Starscream.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = 579C7D4B2731B487009F8A2F /* Starscream.xcframework */; };
2223
6CA08A981D615C0B0061FD2A /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6CA08A971D615C0B0061FD2A /* Security.framework */; };
2324
74BF53581F894326004972D8 /* SocketIO.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO.h */; settings = {ATTRIBUTES = (Public, ); }; };
24-
74D0F5961F8053950037C4DC /* Starscream.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9432E00B1F77F883006AF628 /* Starscream.framework */; };
2525
74DA21741F09440F009C19EE /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 74DA21731F09440F009C19EE /* libz.tbd */; };
2626
74DA217C1F09457B009C19EE /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = 74DA21731F09440F009C19EE /* libz.tbd */; };
2727
DD52B048C71D724ABBD18C71 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = DD52BDC9E66AADA2CC5E8246 /* SocketTypes.swift */; };
@@ -75,18 +75,15 @@
7575
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7676
572EF23C1B51F18A00EEBB58 /* SocketIO.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SocketIO.h; sourceTree = "<group>"; };
7777
572EF2421B51F18A00EEBB58 /* SocketIO-Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
78+
579C7D4B2731B487009F8A2F /* Starscream.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = Starscream.xcframework; path = Carthage/Build/Starscream.xcframework; sourceTree = "<group>"; };
7879
6CA08A951D615C040061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.3.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
7980
6CA08A971D615C0B0061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
8081
6CA08A991D615C140061FD2A /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.2.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; };
81-
749FA19F1F8112E7002FBB30 /* Starscream.framework.dSYM */ = {isa = PBXFileReference; lastKnownFileType = wrapper.dsym; name = Starscream.framework.dSYM; path = Carthage/Build/Mac/Starscream.framework.dSYM; sourceTree = "<group>"; };
8282
749FA1A11F811408002FBB30 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
8383
74D0F58D1F804FED0037C4DC /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/usr/lib/libz.tbd; sourceTree = DEVELOPER_DIR; };
8484
74DA21731F09440F009C19EE /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
8585
74DA217D1F0945E9009C19EE /* libcommonCrypto.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libcommonCrypto.tbd; path = usr/lib/system/libcommonCrypto.tbd; sourceTree = SDKROOT; };
8686
9432E0061F77F7CA006AF628 /* SSLSecurity.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSLSecurity.swift; sourceTree = "<group>"; };
87-
9432E0091F77F87D006AF628 /* Starscream.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Starscream.framework; path = Carthage/Build/iOS/Starscream.framework; sourceTree = "<group>"; };
88-
9432E00B1F77F883006AF628 /* Starscream.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Starscream.framework; path = Carthage/Build/Mac/Starscream.framework; sourceTree = "<group>"; };
89-
9432E00D1F77F889006AF628 /* Starscream.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Starscream.framework; path = Carthage/Build/tvOS/Starscream.framework; sourceTree = "<group>"; };
9087
DD52B078DB0A3C3D1BB507CD /* SocketIOClientOption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketIOClientOption.swift; sourceTree = "<group>"; };
9188
DD52B09F7984E730513AB7E5 /* SocketAckManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketAckManager.swift; sourceTree = "<group>"; };
9289
DD52B1D9BC4AE46D38D827DE /* SocketIOStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketIOStatus.swift; sourceTree = "<group>"; };
@@ -120,8 +117,8 @@
120117
buildActionMask = 2147483647;
121118
files = (
122119
74DA21741F09440F009C19EE /* libz.tbd in Frameworks */,
120+
579C7D4C2731B487009F8A2F /* Starscream.xcframework in Frameworks */,
123121
6CA08A981D615C0B0061FD2A /* Security.framework in Frameworks */,
124-
74D0F5961F8053950037C4DC /* Starscream.framework in Frameworks */,
125122
);
126123
runOnlyForDeploymentPostprocessing = 0;
127124
};
@@ -231,11 +228,8 @@
231228
isa = PBXGroup;
232229
children = (
233230
749FA1A11F811408002FBB30 /* Foundation.framework */,
234-
749FA19F1F8112E7002FBB30 /* Starscream.framework.dSYM */,
231+
579C7D4B2731B487009F8A2F /* Starscream.xcframework */,
235232
74D0F58D1F804FED0037C4DC /* libz.tbd */,
236-
9432E0091F77F87D006AF628 /* Starscream.framework */,
237-
9432E00B1F77F883006AF628 /* Starscream.framework */,
238-
9432E00D1F77F889006AF628 /* Starscream.framework */,
239233
74DA217D1F0945E9009C19EE /* libcommonCrypto.tbd */,
240234
74DA21731F09440F009C19EE /* libz.tbd */,
241235
6CA08A9E1D615C340061FD2A /* tvOS */,
@@ -541,33 +535,9 @@
541535
"ENABLE_BITCODE[sdk=macosx*]" = NO;
542536
ENABLE_STRICT_OBJC_MSGSEND = YES;
543537
ENABLE_TESTABILITY = YES;
544-
"FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = (
545-
"$(inherited)",
546-
"$(PROJECT_DIR)/Carthage/Build/tvOS",
547-
);
548-
"FRAMEWORK_SEARCH_PATHS[sdk=appletvsimulator*]" = (
549-
"$(inherited)",
550-
"$(PROJECT_DIR)/Carthage/Build/tvOS",
551-
);
552-
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = (
553-
"$(inherited)",
554-
"$(PROJECT_DIR)/Carthage/Build/iOS",
555-
);
556-
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = (
557-
"$(inherited)",
558-
"$(PROJECT_DIR)/Carthage/Build/iOS",
559-
);
560-
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = (
561-
"$(inherited)",
562-
"$(PROJECT_DIR)/Carthage/Build/Mac",
563-
);
564-
"FRAMEWORK_SEARCH_PATHS[sdk=watchos*]" = (
565-
"$(PROJECT_DIR)/Carthage/Build/watchOS",
566-
"$(inherited)",
567-
);
568-
"FRAMEWORK_SEARCH_PATHS[sdk=watchsimulator*]" = (
569-
"$(PROJECT_DIR)/Carthage/Build/watchOS",
538+
FRAMEWORK_SEARCH_PATHS = (
570539
"$(inherited)",
540+
"$(PROJECT_DIR)/Carthage/Build/",
571541
);
572542
GCC_NO_COMMON_BLOCKS = YES;
573543
GCC_OPTIMIZATION_LEVEL = 0;
@@ -616,33 +586,9 @@
616586
ENABLE_BITCODE = YES;
617587
"ENABLE_BITCODE[sdk=macosx*]" = NO;
618588
ENABLE_STRICT_OBJC_MSGSEND = YES;
619-
"FRAMEWORK_SEARCH_PATHS[sdk=appletvos*]" = (
620-
"$(inherited)",
621-
"$(PROJECT_DIR)/Carthage/Build/tvOS",
622-
);
623-
"FRAMEWORK_SEARCH_PATHS[sdk=appletvsimulator*]" = (
624-
"$(inherited)",
625-
"$(PROJECT_DIR)/Carthage/Build/tvOS",
626-
);
627-
"FRAMEWORK_SEARCH_PATHS[sdk=iphoneos*]" = (
628-
"$(inherited)",
629-
"$(PROJECT_DIR)/Carthage/Build/iOS",
630-
);
631-
"FRAMEWORK_SEARCH_PATHS[sdk=iphonesimulator*]" = (
632-
"$(inherited)",
633-
"$(PROJECT_DIR)/Carthage/Build/iOS",
634-
);
635-
"FRAMEWORK_SEARCH_PATHS[sdk=macosx*]" = (
636-
"$(inherited)",
637-
"$(PROJECT_DIR)/Carthage/Build/Mac",
638-
);
639-
"FRAMEWORK_SEARCH_PATHS[sdk=watchos*]" = (
640-
"$(PROJECT_DIR)/Carthage/Build/watchOS",
641-
"$(inherited)",
642-
);
643-
"FRAMEWORK_SEARCH_PATHS[sdk=watchsimulator*]" = (
644-
"$(PROJECT_DIR)/Carthage/Build/watchOS",
589+
FRAMEWORK_SEARCH_PATHS = (
645590
"$(inherited)",
591+
"$(PROJECT_DIR)/Carthage/Build/",
646592
);
647593
GCC_NO_COMMON_BLOCKS = YES;
648594
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
@@ -655,7 +601,8 @@
655601
MACOSX_DEPLOYMENT_TARGET = 10.14;
656602
PRODUCT_NAME = SocketIO;
657603
SUPPORTED_PLATFORMS = "macosx appletvsimulator appletvos iphonesimulator iphoneos watchos watchsimulator";
658-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
604+
SWIFT_COMPILATION_MODE = wholemodule;
605+
SWIFT_OPTIMIZATION_LEVEL = "-O";
659606
SWIFT_VERSION = 5.0;
660607
TVOS_DEPLOYMENT_TARGET = 10.0;
661608
VALID_ARCHS = "i386 x86_64 armv7 armv7s arm64 armv7k";
@@ -712,8 +659,16 @@
712659
GCC_WARN_UNUSED_VARIABLE = YES;
713660
INFOPLIST_FILE = SocketIO/Info.plist;
714661
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
715-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
716-
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
662+
LD_RUNPATH_SEARCH_PATHS = (
663+
"$(inherited)",
664+
"@executable_path/Frameworks",
665+
"@loader_path/Frameworks",
666+
);
667+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
668+
"$(inherited)",
669+
"@executable_path/../Frameworks",
670+
"@loader_path/../Frameworks",
671+
);
717672
LIBRARY_SEARCH_PATHS = "$(inherited)";
718673
MACOSX_DEPLOYMENT_TARGET = 10.10;
719674
MTL_ENABLE_DEBUG_INFO = YES;
@@ -722,6 +677,7 @@
722677
SDKROOT = macosx;
723678
SKIP_INSTALL = YES;
724679
SUPPORTED_PLATFORMS = "$(inherited)";
680+
SUPPORTS_MACCATALYST = YES;
725681
SWIFT_INCLUDE_PATHS = "";
726682
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
727683
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
@@ -778,15 +734,24 @@
778734
GCC_WARN_UNUSED_VARIABLE = YES;
779735
INFOPLIST_FILE = SocketIO/Info.plist;
780736
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
781-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
782-
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
737+
LD_RUNPATH_SEARCH_PATHS = (
738+
"$(inherited)",
739+
"@executable_path/Frameworks",
740+
"@loader_path/Frameworks",
741+
);
742+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
743+
"$(inherited)",
744+
"@executable_path/../Frameworks",
745+
"@loader_path/../Frameworks",
746+
);
783747
LIBRARY_SEARCH_PATHS = "$(inherited)";
784748
MACOSX_DEPLOYMENT_TARGET = 10.10;
785749
MTL_ENABLE_DEBUG_INFO = NO;
786750
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
787751
SDKROOT = macosx;
788752
SKIP_INSTALL = YES;
789753
SUPPORTED_PLATFORMS = "$(inherited)";
754+
SUPPORTS_MACCATALYST = YES;
790755
SWIFT_INCLUDE_PATHS = "";
791756
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
792757
SWIFT_VERSION = 5.0;
@@ -862,8 +827,15 @@
862827
GCC_WARN_UNUSED_FUNCTION = YES;
863828
GCC_WARN_UNUSED_VARIABLE = YES;
864829
INFOPLIST_FILE = SocketIO/Info.plist;
865-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
866-
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks @loader_path/../Frameworks";
830+
LD_RUNPATH_SEARCH_PATHS = (
831+
"$(inherited)",
832+
"@executable_path/Frameworks",
833+
"@loader_path/Frameworks",
834+
);
835+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
836+
"@executable_path/../Frameworks",
837+
"@loader_path/../Frameworks",
838+
);
867839
LIBRARY_SEARCH_PATHS = "$(inherited)";
868840
MACOSX_DEPLOYMENT_TARGET = 10.10;
869841
MTL_ENABLE_DEBUG_INFO = YES;
@@ -938,8 +910,15 @@
938910
GCC_WARN_UNUSED_FUNCTION = YES;
939911
GCC_WARN_UNUSED_VARIABLE = YES;
940912
INFOPLIST_FILE = SocketIO/Info.plist;
941-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
942-
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks @loader_path/../Frameworks";
913+
LD_RUNPATH_SEARCH_PATHS = (
914+
"$(inherited)",
915+
"@executable_path/Frameworks",
916+
"@loader_path/Frameworks",
917+
);
918+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
919+
"@executable_path/../Frameworks",
920+
"@loader_path/../Frameworks",
921+
);
943922
LIBRARY_SEARCH_PATHS = "$(inherited)";
944923
MACOSX_DEPLOYMENT_TARGET = 10.10;
945924
MTL_ENABLE_DEBUG_INFO = NO;

Source/SocketIO/Engine/SocketEngine.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -751,7 +751,7 @@ extension SocketEngine {
751751
case .cancelled:
752752
wsConnected = false
753753
websocketDidDisconnect(error: EngineError.canceled)
754-
case let .disconnected(reason, code):
754+
case .disconnected(_, _):
755755
wsConnected = false
756756
websocketDidDisconnect(error: nil)
757757
case let .text(msg):

Source/SocketIO/Engine/SocketEngineSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import Foundation
2727
import Starscream
2828

2929
/// Specifies a SocketEngine.
30-
public protocol SocketEngineSpec: class {
30+
public protocol SocketEngineSpec: AnyObject {
3131
// MARK: Properties
3232

3333
/// The client for this engine.

Source/SocketIO/Manager/SocketManagerSpec.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import Foundation
4545
/// To disconnect a socket and remove it from the manager, either call `SocketIOClient.disconnect()` on the socket,
4646
/// or call one of the `disconnectSocket` methods on this class.
4747
///
48-
public protocol SocketManagerSpec : AnyObject, SocketEngineClient {
48+
public protocol SocketManagerSpec : SocketEngineClient {
4949
// MARK: Properties
5050

5151
/// Returns the socket associated with the default namespace ("/").

Usage Docs/15to16.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,30 @@ This guide will help you navigate the changes that were introduced in v16.
66

77
## Client supports multiple socket.io versions
88

9-
The client now supports socket.io 3 servers. This is mostly a transparent change, however if your sever
9+
The client now supports socket.io 3 servers. This is mostly a transparent change, however if your server
1010
is socket.io 2, you must send `.version(.two)` as an option to the manager.
1111

1212
```swift
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

Lines changed: 61 additions & 0 deletions
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)