commit
e07ed93c0b
11
.travis.yml
11
.travis.yml
@ -2,9 +2,12 @@ language: objective-c
|
|||||||
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
|
xcode_project: Socket.IO-Client-Swift.xcodeproj # path to your xcodeproj folder
|
||||||
xcode_scheme: SocketIO-iOS
|
xcode_scheme: SocketIO-iOS
|
||||||
osx_image: xcode7
|
osx_image: xcode7
|
||||||
script: xcodebuild -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-iOS -sdk iphonesimulator build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
|
before_install:
|
||||||
before_install:
|
- cd Socket.IO-Test-Server/
|
||||||
install: cd Socket.IO-Test-Server/ && npm install && cd .. && node Socket.IO-Test-Server/main.js &
|
- npm install
|
||||||
|
- cd ..
|
||||||
|
install: node Socket.IO-Test-Server/main.js &
|
||||||
|
script: xctool -project Socket.IO-Client-Swift.xcodeproj -scheme SocketIO-Mac build test -parallelize
|
||||||
cache:
|
cache:
|
||||||
directories:
|
directories:
|
||||||
- Socket.IO-Test-Server/node_modules
|
- Socket.IO-Test-Server/node_modules
|
||||||
|
|||||||
@ -11,7 +11,6 @@
|
|||||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
||||||
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
572EF23D1B51F18A00EEBB58 /* SocketIO-Mac.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
|
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */; };
|
||||||
572EF24A1B51F18A00EEBB58 /* SocketIO_MacTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */; };
|
|
||||||
5764DF891B51F254004FF46E /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
5764DF891B51F254004FF46E /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||||
5764DF8A1B51F254004FF46E /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
5764DF8A1B51F254004FF46E /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||||
5764DF8B1B51F254004FF46E /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
5764DF8B1B51F254004FF46E /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||||
@ -38,6 +37,28 @@
|
|||||||
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||||
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||||
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||||
|
741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
745895381BB59A0A0050ACC8 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||||
|
7458953D1BB59A0A0050ACC8 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||||
|
7472A5E11BB6ECE800CD4F59 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||||
|
7472A5E21BB6ECE800CD4F59 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||||
|
7472A5E31BB6ECE800CD4F59 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||||
|
7472A5E41BB6ECE800CD4F59 /* SocketEngineClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */; };
|
||||||
|
7472A5E51BB6ECE800CD4F59 /* SocketEventHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF801B51F254004FF46E /* SocketEventHandler.swift */; };
|
||||||
|
7472A5E61BB6ECE800CD4F59 /* SocketFixUTF8.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF811B51F254004FF46E /* SocketFixUTF8.swift */; };
|
||||||
|
7472A5E71BB6ECE800CD4F59 /* SocketIOClient.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF821B51F254004FF46E /* SocketIOClient.swift */; };
|
||||||
|
7472A5E81BB6ECE800CD4F59 /* SocketLogger.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF831B51F254004FF46E /* SocketLogger.swift */; };
|
||||||
|
7472A5E91BB6ECE800CD4F59 /* SocketPacket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF841B51F254004FF46E /* SocketPacket.swift */; };
|
||||||
|
7472A5EA1BB6ECE800CD4F59 /* SocketParser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF851B51F254004FF46E /* SocketParser.swift */; };
|
||||||
|
7472A5EB1BB6ECE800CD4F59 /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||||
|
7472A5EC1BB6ECE800CD4F59 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||||
|
7472A5ED1BB6ECE800CD4F59 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||||
|
7472A5EE1BB6ECE800CD4F59 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||||
|
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
74781D5A1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
74781D5A1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||||
74781D5B1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
74781D5B1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||||
74781D5C1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
74781D5C1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74781D591B7E83930042CACA /* SocketIOClientStatus.swift */; };
|
||||||
@ -49,8 +70,16 @@
|
|||||||
74D765621B9F0D870028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
74D765621B9F0D870028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||||
74D765631B9F0D9F0028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
74D765631B9F0D9F0028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||||
74D765641B9F0DA40028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
74D765641B9F0DA40028551C /* SocketStringReader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74D765611B9F0D870028551C /* SocketStringReader.swift */; };
|
||||||
941A4ABA1B67A56C00C42318 /* TestKind.swift in Sources */ = {isa = PBXBuildFile; fileRef = 941A4AB91B67A56C00C42318 /* TestKind.swift */; };
|
74F124E31BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
94242BB81B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */; };
|
74F124E41BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124E51BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124E61BC5697B002966F4 /* SocketEngineSpec.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124E81BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124E91BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124EA1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124EB1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
|
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */; settings = {ASSET_TAGS = (); }; };
|
||||||
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7C1B51F254004FF46E /* SocketAckManager.swift */; };
|
||||||
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */; };
|
||||||
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF7E1B51F254004FF46E /* SocketEngine.swift */; };
|
||||||
@ -64,13 +93,8 @@
|
|||||||
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF861B51F254004FF46E /* SocketTypes.swift */; };
|
||||||
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF871B51F254004FF46E /* SwiftRegex.swift */; };
|
||||||
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5764DF881B51F254004FF46E /* WebSocket.swift */; };
|
||||||
945B65431B63D9DB0081E995 /* SocketEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 945B65421B63D9DB0081E995 /* SocketEmitTest.swift */; };
|
|
||||||
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */; };
|
||||||
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */; };
|
||||||
94ADAC491B652D3300FD79AE /* SocketNamespaceEmitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */; };
|
|
||||||
94ADAC4B1B6632DD00FD79AE /* SocketAcknowledgementTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */; };
|
|
||||||
94CB8F0B1B6E48B90019ED53 /* SocketTestCases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */; };
|
|
||||||
94CB8F0D1B6E66E60019ED53 /* AbstractSocketTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */; };
|
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
/* Begin PBXContainerItemProxy section */
|
/* Begin PBXContainerItemProxy section */
|
||||||
@ -101,7 +125,6 @@
|
|||||||
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = "<group>"; };
|
572EF23C1B51F18A00EEBB58 /* SocketIO-Mac.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-Mac.h"; sourceTree = "<group>"; };
|
||||||
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-MacTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF2481B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF2481B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SocketIO_MacTests.swift; sourceTree = "<group>"; };
|
|
||||||
5764DF7C1B51F254004FF46E /* SocketAckManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManager.swift; path = SocketIOClientSwift/SocketAckManager.swift; sourceTree = "<group>"; };
|
5764DF7C1B51F254004FF46E /* SocketAckManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManager.swift; path = SocketIOClientSwift/SocketAckManager.swift; sourceTree = "<group>"; };
|
||||||
5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAnyEvent.swift; path = SocketIOClientSwift/SocketAnyEvent.swift; sourceTree = "<group>"; };
|
5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAnyEvent.swift; path = SocketIOClientSwift/SocketAnyEvent.swift; sourceTree = "<group>"; };
|
||||||
5764DF7E1B51F254004FF46E /* SocketEngine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEngine.swift; path = SocketIOClientSwift/SocketEngine.swift; sourceTree = "<group>"; };
|
5764DF7E1B51F254004FF46E /* SocketEngine.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEngine.swift; path = SocketIOClientSwift/SocketEngine.swift; sourceTree = "<group>"; };
|
||||||
@ -115,18 +138,17 @@
|
|||||||
5764DF861B51F254004FF46E /* SocketTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = SocketIOClientSwift/SocketTypes.swift; sourceTree = "<group>"; };
|
5764DF861B51F254004FF46E /* SocketTypes.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketTypes.swift; path = SocketIOClientSwift/SocketTypes.swift; sourceTree = "<group>"; };
|
||||||
5764DF871B51F254004FF46E /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftRegex.swift; path = SocketIOClientSwift/SwiftRegex.swift; sourceTree = "<group>"; };
|
5764DF871B51F254004FF46E /* SwiftRegex.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SwiftRegex.swift; path = SocketIOClientSwift/SwiftRegex.swift; sourceTree = "<group>"; };
|
||||||
5764DF881B51F254004FF46E /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = SocketIOClientSwift/WebSocket.swift; sourceTree = "<group>"; };
|
5764DF881B51F254004FF46E /* WebSocket.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = WebSocket.swift; path = SocketIOClientSwift/WebSocket.swift; sourceTree = "<group>"; };
|
||||||
|
741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketEngineTest.swift; sourceTree = "<group>"; };
|
||||||
|
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespacePacketTest.swift; sourceTree = "<group>"; };
|
||||||
|
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketSideEffectTest.swift; sourceTree = "<group>"; };
|
||||||
74781D591B7E83930042CACA /* SocketIOClientStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientStatus.swift; path = SocketIOClientSwift/SocketIOClientStatus.swift; sourceTree = "<group>"; };
|
74781D591B7E83930042CACA /* SocketIOClientStatus.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketIOClientStatus.swift; path = SocketIOClientSwift/SocketIOClientStatus.swift; sourceTree = "<group>"; };
|
||||||
749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckEmitter.swift; path = SocketIOClientSwift/SocketAckEmitter.swift; sourceTree = "<group>"; };
|
749A7F8A1BA9D42D00782993 /* SocketAckEmitter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckEmitter.swift; path = SocketIOClientSwift/SocketAckEmitter.swift; sourceTree = "<group>"; };
|
||||||
74D765611B9F0D870028551C /* SocketStringReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SocketStringReader.swift; path = SocketIOClientSwift/SocketStringReader.swift; sourceTree = "<group>"; };
|
74D765611B9F0D870028551C /* SocketStringReader.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = SocketStringReader.swift; path = SocketIOClientSwift/SocketStringReader.swift; sourceTree = "<group>"; };
|
||||||
941A4AB91B67A56C00C42318 /* TestKind.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestKind.swift; sourceTree = "<group>"; };
|
74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEngineSpec.swift; path = SocketIOClientSwift/SocketEngineSpec.swift; sourceTree = "<group>"; };
|
||||||
94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespaceAcknowledgementTest.swift; sourceTree = "<group>"; };
|
74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketEnginePacketType.swift; path = SocketIOClientSwift/SocketEnginePacketType.swift; sourceTree = "<group>"; };
|
||||||
945B65421B63D9DB0081E995 /* SocketEmitTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketEmitTest.swift; sourceTree = "<group>"; };
|
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketBasicPacketTest.swift; sourceTree = "<group>"; };
|
||||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketParserTest.swift; sourceTree = "<group>"; };
|
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketParserTest.swift; path = "../SocketIO-iOSTests/SocketParserTest.swift"; sourceTree = "<group>"; };
|
||||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketAckManagerTest.swift; sourceTree = "<group>"; };
|
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SocketAckManagerTest.swift; path = "../SocketIO-iOSTests/SocketAckManagerTest.swift"; sourceTree = "<group>"; };
|
||||||
94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketNamespaceEmitTest.swift; sourceTree = "<group>"; };
|
|
||||||
94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketAcknowledgementTest.swift; sourceTree = "<group>"; };
|
|
||||||
94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SocketTestCases.swift; sourceTree = "<group>"; };
|
|
||||||
94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AbstractSocketTest.swift; sourceTree = "<group>"; };
|
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
/* Begin PBXFrameworksBuildPhase section */
|
/* Begin PBXFrameworksBuildPhase section */
|
||||||
@ -206,15 +228,6 @@
|
|||||||
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
572EF2281B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */,
|
|
||||||
94ADAC4A1B6632DD00FD79AE /* SocketAcknowledgementTest.swift */,
|
|
||||||
945B65421B63D9DB0081E995 /* SocketEmitTest.swift */,
|
|
||||||
94ADAC481B652D3300FD79AE /* SocketNamespaceEmitTest.swift */,
|
|
||||||
94242BB71B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift */,
|
|
||||||
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */,
|
|
||||||
94CB8F0A1B6E48B90019ED53 /* SocketTestCases.swift */,
|
|
||||||
94CB8F0C1B6E66E60019ED53 /* AbstractSocketTest.swift */,
|
|
||||||
941A4AB91B67A56C00C42318 /* TestKind.swift */,
|
|
||||||
572EF2291B51F16C00EEBB58 /* Supporting Files */,
|
572EF2291B51F16C00EEBB58 /* Supporting Files */,
|
||||||
);
|
);
|
||||||
path = "SocketIO-iOSTests";
|
path = "SocketIO-iOSTests";
|
||||||
@ -248,7 +261,12 @@
|
|||||||
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
572EF2461B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
572EF2491B51F18A00EEBB58 /* SocketIO_MacTests.swift */,
|
94A20D601B99E22F00BF9E44 /* SocketAckManagerTest.swift */,
|
||||||
|
74F124EF1BC574CF002966F4 /* SocketBasicPacketTest.swift */,
|
||||||
|
741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */,
|
||||||
|
7472C65B1BCAB53E003CA70D /* SocketNamespacePacketTest.swift */,
|
||||||
|
949FAE8C1B9B94E600073BE9 /* SocketParserTest.swift */,
|
||||||
|
7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */,
|
||||||
572EF2471B51F18A00EEBB58 /* Supporting Files */,
|
572EF2471B51F18A00EEBB58 /* Supporting Files */,
|
||||||
);
|
);
|
||||||
path = "SocketIO-MacTests";
|
path = "SocketIO-MacTests";
|
||||||
@ -270,6 +288,8 @@
|
|||||||
5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */,
|
5764DF7D1B51F254004FF46E /* SocketAnyEvent.swift */,
|
||||||
5764DF7E1B51F254004FF46E /* SocketEngine.swift */,
|
5764DF7E1B51F254004FF46E /* SocketEngine.swift */,
|
||||||
5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */,
|
5764DF7F1B51F254004FF46E /* SocketEngineClient.swift */,
|
||||||
|
74F124E71BC56BFC002966F4 /* SocketEnginePacketType.swift */,
|
||||||
|
74F124E21BC5697B002966F4 /* SocketEngineSpec.swift */,
|
||||||
5764DF801B51F254004FF46E /* SocketEventHandler.swift */,
|
5764DF801B51F254004FF46E /* SocketEventHandler.swift */,
|
||||||
5764DF811B51F254004FF46E /* SocketFixUTF8.swift */,
|
5764DF811B51F254004FF46E /* SocketFixUTF8.swift */,
|
||||||
5764DF821B51F254004FF46E /* SocketIOClient.swift */,
|
5764DF821B51F254004FF46E /* SocketIOClient.swift */,
|
||||||
@ -472,7 +492,9 @@
|
|||||||
74781D5A1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
74781D5A1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||||
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */,
|
5764DFA11B51F254004FF46E /* WebSocket.swift in Sources */,
|
||||||
5764DF991B51F254004FF46E /* SocketPacket.swift in Sources */,
|
5764DF991B51F254004FF46E /* SocketPacket.swift in Sources */,
|
||||||
|
74F124E31BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||||
5764DF891B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
5764DF891B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
||||||
|
74F124E81BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||||
5764DF9F1B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
5764DF9F1B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -486,26 +508,25 @@
|
|||||||
945B653D1B5FCEEA0081E995 /* SocketPacket.swift in Sources */,
|
945B653D1B5FCEEA0081E995 /* SocketPacket.swift in Sources */,
|
||||||
945B653A1B5FCEEA0081E995 /* SocketFixUTF8.swift in Sources */,
|
945B653A1B5FCEEA0081E995 /* SocketFixUTF8.swift in Sources */,
|
||||||
945B65391B5FCEEA0081E995 /* SocketEventHandler.swift in Sources */,
|
945B65391B5FCEEA0081E995 /* SocketEventHandler.swift in Sources */,
|
||||||
94CB8F0B1B6E48B90019ED53 /* SocketTestCases.swift in Sources */,
|
|
||||||
749A7F8C1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
749A7F8C1BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
||||||
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */,
|
945B65371B5FCEEA0081E995 /* SocketEngine.swift in Sources */,
|
||||||
|
7472C65F1BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||||
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */,
|
945B65351B5FCEEA0081E995 /* SocketAckManager.swift in Sources */,
|
||||||
941A4ABA1B67A56C00C42318 /* TestKind.swift in Sources */,
|
|
||||||
94CB8F0D1B6E66E60019ED53 /* AbstractSocketTest.swift in Sources */,
|
|
||||||
945B65431B63D9DB0081E995 /* SocketEmitTest.swift in Sources */,
|
|
||||||
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */,
|
945B65401B5FCEEA0081E995 /* SwiftRegex.swift in Sources */,
|
||||||
945B653C1B5FCEEA0081E995 /* SocketLogger.swift in Sources */,
|
945B653C1B5FCEEA0081E995 /* SocketLogger.swift in Sources */,
|
||||||
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */,
|
94A20D611B99E22F00BF9E44 /* SocketAckManagerTest.swift in Sources */,
|
||||||
|
74F124E41BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||||
945B65381B5FCEEA0081E995 /* SocketEngineClient.swift in Sources */,
|
945B65381B5FCEEA0081E995 /* SocketEngineClient.swift in Sources */,
|
||||||
|
741F39EE1BD025D80026C9CC /* SocketEngineTest.swift in Sources */,
|
||||||
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */,
|
945B65361B5FCEEA0081E995 /* SocketAnyEvent.swift in Sources */,
|
||||||
94ADAC4B1B6632DD00FD79AE /* SocketAcknowledgementTest.swift in Sources */,
|
|
||||||
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */,
|
945B653F1B5FCEEA0081E995 /* SocketTypes.swift in Sources */,
|
||||||
74781D5B1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
74781D5B1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||||
945B653B1B5FCEEA0081E995 /* SocketIOClient.swift in Sources */,
|
945B653B1B5FCEEA0081E995 /* SocketIOClient.swift in Sources */,
|
||||||
|
74F124F01BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */,
|
||||||
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */,
|
949FAE8D1B9B94E600073BE9 /* SocketParserTest.swift in Sources */,
|
||||||
94ADAC491B652D3300FD79AE /* SocketNamespaceEmitTest.swift in Sources */,
|
7472C65C1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||||
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */,
|
945B65411B5FCEEA0081E995 /* WebSocket.swift in Sources */,
|
||||||
94242BB81B67B0E500AAAC9D /* SocketNamespaceAcknowledgementTest.swift in Sources */,
|
74F124E91BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -527,7 +548,9 @@
|
|||||||
74781D5C1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
74781D5C1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||||
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */,
|
5764DFA21B51F254004FF46E /* WebSocket.swift in Sources */,
|
||||||
5764DF9A1B51F254004FF46E /* SocketPacket.swift in Sources */,
|
5764DF9A1B51F254004FF46E /* SocketPacket.swift in Sources */,
|
||||||
|
74F124E51BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||||
5764DF8A1B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
5764DF8A1B51F254004FF46E /* SocketAckManager.swift in Sources */,
|
||||||
|
74F124EA1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||||
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
5764DFA01B51F254004FF46E /* SwiftRegex.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -536,8 +559,29 @@
|
|||||||
isa = PBXSourcesBuildPhase;
|
isa = PBXSourcesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
|
7472A5E11BB6ECE800CD4F59 /* SocketAckManager.swift in Sources */,
|
||||||
|
7472A5E21BB6ECE800CD4F59 /* SocketAnyEvent.swift in Sources */,
|
||||||
|
74F124E61BC5697B002966F4 /* SocketEngineSpec.swift in Sources */,
|
||||||
|
7472A5E31BB6ECE800CD4F59 /* SocketEngine.swift in Sources */,
|
||||||
|
7472A5E41BB6ECE800CD4F59 /* SocketEngineClient.swift in Sources */,
|
||||||
|
7472A5E51BB6ECE800CD4F59 /* SocketEventHandler.swift in Sources */,
|
||||||
|
7472A5E61BB6ECE800CD4F59 /* SocketFixUTF8.swift in Sources */,
|
||||||
|
7472C6601BCAC46E003CA70D /* SocketSideEffectTest.swift in Sources */,
|
||||||
|
7472A5E71BB6ECE800CD4F59 /* SocketIOClient.swift in Sources */,
|
||||||
|
7472A5E81BB6ECE800CD4F59 /* SocketLogger.swift in Sources */,
|
||||||
|
7472A5E91BB6ECE800CD4F59 /* SocketPacket.swift in Sources */,
|
||||||
|
7472A5EA1BB6ECE800CD4F59 /* SocketParser.swift in Sources */,
|
||||||
|
7472A5EB1BB6ECE800CD4F59 /* SocketStringReader.swift in Sources */,
|
||||||
|
7472A5EC1BB6ECE800CD4F59 /* SocketTypes.swift in Sources */,
|
||||||
|
741F39EF1BD025D80026C9CC /* SocketEngineTest.swift in Sources */,
|
||||||
|
7472A5ED1BB6ECE800CD4F59 /* SwiftRegex.swift in Sources */,
|
||||||
|
7472A5EE1BB6ECE800CD4F59 /* WebSocket.swift in Sources */,
|
||||||
|
745895381BB59A0A0050ACC8 /* SocketAckManagerTest.swift in Sources */,
|
||||||
|
7458953D1BB59A0A0050ACC8 /* SocketParserTest.swift in Sources */,
|
||||||
|
74F124F11BC574CF002966F4 /* SocketBasicPacketTest.swift in Sources */,
|
||||||
|
74F124EB1BC56BFC002966F4 /* SocketEnginePacketType.swift in Sources */,
|
||||||
|
7472C65D1BCAB53E003CA70D /* SocketNamespacePacketTest.swift in Sources */,
|
||||||
749A7F901BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
749A7F901BA9D42D00782993 /* SocketAckEmitter.swift in Sources */,
|
||||||
572EF24A1B51F18A00EEBB58 /* SocketIO_MacTests.swift in Sources */,
|
|
||||||
74781D5D1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
74781D5D1B7E83930042CACA /* SocketIOClientStatus.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -901,6 +945,7 @@
|
|||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "";
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
@ -951,6 +996,7 @@
|
|||||||
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
|
||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
|
CODE_SIGN_IDENTITY = "";
|
||||||
COMBINE_HIDPI_IMAGES = YES;
|
COMBINE_HIDPI_IMAGES = YES;
|
||||||
COPY_PHASE_STRIP = NO;
|
COPY_PHASE_STRIP = NO;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
|
|||||||
139
SocketIO-MacTests/SocketBasicPacketTest.swift
Normal file
139
SocketIO-MacTests/SocketBasicPacketTest.swift
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
//
|
||||||
|
// SocketBasicPacketTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Erik Little on 10/7/15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class SocketBasicPacketTest: XCTestCase {
|
||||||
|
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
let data2 = "test2".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
|
||||||
|
func testEmpyEmit() {
|
||||||
|
let expectedSendString = "2[\"test\"]"
|
||||||
|
let sendData = ["test"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNullEmit() {
|
||||||
|
let expectedSendString = "2[\"test\",null]"
|
||||||
|
let sendData = ["test", NSNull()]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testStringEmit() {
|
||||||
|
let expectedSendString = "2[\"test\",\"foo bar\"]"
|
||||||
|
let sendData = ["test", "foo bar"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONEmit() {
|
||||||
|
let expectedSendString = "2[\"test\",{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||||
|
let sendData = ["test", ["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testArrayEmit() {
|
||||||
|
let expectedSendString = "2[\"test\",[\"hello\",1,{\"test\":\"test\"}]]"
|
||||||
|
let sendData = ["test", ["hello", 1, ["test": "test"]]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinaryEmit() {
|
||||||
|
let expectedSendString = "51-[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||||
|
let sendData = ["test", data]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleBinaryEmit() {
|
||||||
|
let expectedSendString = "52-[\"test\",{\"data1\":{\"num\":0,\"_placeholder\":true},\"data2\":{\"num\":1,\"_placeholder\":true}}]"
|
||||||
|
let sendData = ["test", ["data1": data, "data2": data2]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data, data2])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testEmitWithAck() {
|
||||||
|
let expectedSendString = "20[\"test\"]"
|
||||||
|
let sendData = ["test"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testEmitDataWithAck() {
|
||||||
|
let expectedSendString = "51-0[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||||
|
let sendData = ["test", data]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acks
|
||||||
|
func testEmptyAck() {
|
||||||
|
let expectedSendString = "30[]"
|
||||||
|
let packet = SocketPacket.packetFromEmit([], id: 0, nsp: "/", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNullAck() {
|
||||||
|
let expectedSendString = "30[null]"
|
||||||
|
let sendData = [NSNull()]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testStringAck() {
|
||||||
|
let expectedSendString = "30[\"test\"]"
|
||||||
|
let sendData = ["test"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONAck() {
|
||||||
|
let expectedSendString = "30[{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||||
|
let sendData = [["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinaryAck() {
|
||||||
|
let expectedSendString = "61-0[{\"num\":0,\"_placeholder\":true}]"
|
||||||
|
let sendData = [data]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleBinaryAck() {
|
||||||
|
let expectedSendString = "62-0[{\"data2\":{\"num\":0,\"_placeholder\":true},\"data1\":{\"num\":1,\"_placeholder\":true}}]"
|
||||||
|
let sendData = [["data1": data, "data2": data2]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data2, data])
|
||||||
|
}
|
||||||
|
}
|
||||||
52
SocketIO-MacTests/SocketEngineTest.swift
Normal file
52
SocketIO-MacTests/SocketEngineTest.swift
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
//
|
||||||
|
// SocketEngineTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Erik Little on 10/15/15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class SocketEngineTest: XCTestCase {
|
||||||
|
var client: SocketIOClient!
|
||||||
|
var engine: SocketEngine!
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
super.setUp()
|
||||||
|
client = SocketIOClient(socketURL: "")
|
||||||
|
engine = SocketEngine(client: client, opts: nil)
|
||||||
|
|
||||||
|
client.setTestable()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBasicPollingMessage() {
|
||||||
|
let expectation = expectationWithDescription("Basic polling test")
|
||||||
|
client.on("blankTest") {data, ack in
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.parsePollingMessage("15:42[\"blankTest\"]")
|
||||||
|
waitForExpectationsWithTimeout(3, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testTwoPacketsInOnePollTest() {
|
||||||
|
let finalExpectation = expectationWithDescription("Final packet in poll test")
|
||||||
|
var gotBlank = false
|
||||||
|
|
||||||
|
client.on("blankTest") {data, ack in
|
||||||
|
gotBlank = true
|
||||||
|
}
|
||||||
|
|
||||||
|
client.on("stringTest") {data, ack in
|
||||||
|
if let str = data[0] as? String where gotBlank {
|
||||||
|
if str == "hello" {
|
||||||
|
finalExpectation.fulfill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
engine.parsePollingMessage("15:42[\"blankTest\"]24:42[\"stringTest\",\"hello\"]")
|
||||||
|
waitForExpectationsWithTimeout(3, handler: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,36 +0,0 @@
|
|||||||
//
|
|
||||||
// SocketIO_MacTests.swift
|
|
||||||
// SocketIO-MacTests
|
|
||||||
//
|
|
||||||
// Created by Nacho Soto on 7/11/15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import Cocoa
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
class SocketIO_MacTests: XCTestCase {
|
|
||||||
|
|
||||||
override func setUp() {
|
|
||||||
super.setUp()
|
|
||||||
// Put setup code here. This method is called before the invocation of each test method in the class.
|
|
||||||
}
|
|
||||||
|
|
||||||
override func tearDown() {
|
|
||||||
// Put teardown code here. This method is called after the invocation of each test method in the class.
|
|
||||||
super.tearDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
func testExample() {
|
|
||||||
// This is an example of a functional test case.
|
|
||||||
XCTAssert(true, "Pass")
|
|
||||||
}
|
|
||||||
|
|
||||||
func testPerformanceExample() {
|
|
||||||
// This is an example of a performance test case.
|
|
||||||
self.measureBlock() {
|
|
||||||
// Put the code you want to measure the time of here.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
139
SocketIO-MacTests/SocketNamespacePacketTest.swift
Normal file
139
SocketIO-MacTests/SocketNamespacePacketTest.swift
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
//
|
||||||
|
// SocketNamespacePacketTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Erik Little on 10/11/15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class SocketNamespacePacketTest: XCTestCase {
|
||||||
|
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
let data2 = "test2".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
|
||||||
|
func testEmpyEmit() {
|
||||||
|
let expectedSendString = "2/swift,[\"test\"]"
|
||||||
|
let sendData = ["test"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNullEmit() {
|
||||||
|
let expectedSendString = "2/swift,[\"test\",null]"
|
||||||
|
let sendData = ["test", NSNull()]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testStringEmit() {
|
||||||
|
let expectedSendString = "2/swift,[\"test\",\"foo bar\"]"
|
||||||
|
let sendData = ["test", "foo bar"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONEmit() {
|
||||||
|
let expectedSendString = "2/swift,[\"test\",{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||||
|
let sendData = ["test", ["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testArrayEmit() {
|
||||||
|
let expectedSendString = "2/swift,[\"test\",[\"hello\",1,{\"test\":\"test\"}]]"
|
||||||
|
let sendData = ["test", ["hello", 1, ["test": "test"]]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinaryEmit() {
|
||||||
|
let expectedSendString = "51-/swift,[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||||
|
let sendData = ["test", data]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleBinaryEmit() {
|
||||||
|
let expectedSendString = "52-/swift,[\"test\",{\"data1\":{\"num\":0,\"_placeholder\":true},\"data2\":{\"num\":1,\"_placeholder\":true}}]"
|
||||||
|
let sendData = ["test", ["data1": data, "data2": data2]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: -1, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data, data2])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testEmitWithAck() {
|
||||||
|
let expectedSendString = "2/swift,0[\"test\"]"
|
||||||
|
let sendData = ["test"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testEmitDataWithAck() {
|
||||||
|
let expectedSendString = "51-/swift,0[\"test\",{\"num\":0,\"_placeholder\":true}]"
|
||||||
|
let sendData = ["test", data]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: false)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acks
|
||||||
|
func testEmptyAck() {
|
||||||
|
let expectedSendString = "3/swift,0[]"
|
||||||
|
let packet = SocketPacket.packetFromEmit([], id: 0, nsp: "/swift", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testNullAck() {
|
||||||
|
let expectedSendString = "3/swift,0[null]"
|
||||||
|
let sendData = [NSNull()]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testStringAck() {
|
||||||
|
let expectedSendString = "3/swift,0[\"test\"]"
|
||||||
|
let sendData = ["test"]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testJSONAck() {
|
||||||
|
let expectedSendString = "3/swift,0[{\"test\":\"hello\",\"hello\":1,\"foobar\":true,\"null\":null}]"
|
||||||
|
let sendData = [["foobar": true, "hello": 1, "test": "hello", "null": NSNull()]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinaryAck() {
|
||||||
|
let expectedSendString = "61-/swift,0[{\"num\":0,\"_placeholder\":true}]"
|
||||||
|
let sendData = [data]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data])
|
||||||
|
}
|
||||||
|
|
||||||
|
func testMultipleBinaryAck() {
|
||||||
|
let expectedSendString = "62-/swift,0[{\"data2\":{\"num\":0,\"_placeholder\":true},\"data1\":{\"num\":1,\"_placeholder\":true}}]"
|
||||||
|
let sendData = [["data1": data, "data2": data2]]
|
||||||
|
let packet = SocketPacket.packetFromEmit(sendData, id: 0, nsp: "/swift", ack: true)
|
||||||
|
|
||||||
|
XCTAssertEqual(packet.packetString, expectedSendString)
|
||||||
|
XCTAssertEqual(packet.binary, [data2, data])
|
||||||
|
}
|
||||||
|
}
|
||||||
90
SocketIO-MacTests/SocketSideEffectTest.swift
Normal file
90
SocketIO-MacTests/SocketSideEffectTest.swift
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
//
|
||||||
|
// SocketSideEffectTest.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Erik Little on 10/11/15.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
import XCTest
|
||||||
|
|
||||||
|
class SocketSideEffectTest: XCTestCase {
|
||||||
|
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
let data2 = "test2".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
private var socket: SocketIOClient!
|
||||||
|
|
||||||
|
override func setUp() {
|
||||||
|
super.setUp()
|
||||||
|
socket = SocketIOClient(socketURL: "")
|
||||||
|
socket.setTestable()
|
||||||
|
}
|
||||||
|
|
||||||
|
func testInitialCurrentAck() {
|
||||||
|
XCTAssertEqual(socket.currentAck, -1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testFirstAck() {
|
||||||
|
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||||
|
XCTAssertEqual(socket.currentAck, 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testSecondAck() {
|
||||||
|
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||||
|
socket.emitWithAck("test")(timeoutAfter: 0) {data in}
|
||||||
|
|
||||||
|
XCTAssertEqual(socket.currentAck, 1)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHandleAck() {
|
||||||
|
let expectation = expectationWithDescription("handled ack")
|
||||||
|
socket.emitWithAck("test")(timeoutAfter: 0) {data in
|
||||||
|
XCTAssertEqual(data[0] as? String, "hello world")
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.parseSocketMessage("30[\"hello world\"]")
|
||||||
|
waitForExpectationsWithTimeout(3, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHandleEvent() {
|
||||||
|
let expectation = expectationWithDescription("handled event")
|
||||||
|
socket.on("test") {data, ack in
|
||||||
|
XCTAssertEqual(data[0] as? String, "hello world")
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.parseSocketMessage("2[\"test\",\"hello world\"]")
|
||||||
|
waitForExpectationsWithTimeout(3, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHandleBinaryEvent() {
|
||||||
|
let expectation = expectationWithDescription("handled binary event")
|
||||||
|
socket.on("test") {data, ack in
|
||||||
|
if let dict = data[0] as? NSDictionary, data = dict["test"] as? NSData {
|
||||||
|
XCTAssertEqual(data, self.data)
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.parseSocketMessage("51-[\"test\",{\"test\":{\"_placeholder\":true,\"num\":0}}]")
|
||||||
|
socket.parseBinaryData(data)
|
||||||
|
waitForExpectationsWithTimeout(3, handler: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testHandleMultipleBinaryEvent() {
|
||||||
|
let expectation = expectationWithDescription("handled multiple binary event")
|
||||||
|
socket.on("test") {data, ack in
|
||||||
|
if let dict = data[0] as? NSDictionary, data = dict["test"] as? NSData,
|
||||||
|
data2 = dict["test2"] as? NSData {
|
||||||
|
XCTAssertEqual(data, self.data)
|
||||||
|
XCTAssertEqual(data2, self.data2)
|
||||||
|
expectation.fulfill()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.parseSocketMessage("52-[\"test\",{\"test\":{\"_placeholder\":true,\"num\":0},\"test2\":{\"_placeholder\":true,\"num\":1}}]")
|
||||||
|
socket.parseBinaryData(data)
|
||||||
|
socket.parseBinaryData(data2)
|
||||||
|
waitForExpectationsWithTimeout(3, handler: nil)
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,114 +0,0 @@
|
|||||||
//
|
|
||||||
// AbstractSocketTest.swift
|
|
||||||
// AbstractSocketTest.socket.IO-Client-Swift
|
|
||||||
//
|
|
||||||
// Created by Lukas Schmidt on 02.08.15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
class AbstractSocketTest: XCTestCase {
|
|
||||||
static let serverURL = "localhost:6979"
|
|
||||||
static let TEST_TIMEOUT = 8.0
|
|
||||||
static var socket:SocketIOClient!
|
|
||||||
var testKind:TestKind?
|
|
||||||
|
|
||||||
|
|
||||||
func openConnection() {
|
|
||||||
guard AbstractSocketTest.socket.status == SocketIOClientStatus.NotConnected else {return}
|
|
||||||
|
|
||||||
weak var expection = self.expectationWithDescription("connect")
|
|
||||||
XCTAssertTrue(AbstractSocketTest.socket.status == SocketIOClientStatus.NotConnected)
|
|
||||||
AbstractSocketTest.socket.on("connect") {data, ack in
|
|
||||||
XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connected)
|
|
||||||
XCTAssertFalse(AbstractSocketTest.socket.secure)
|
|
||||||
if let expection = expection {
|
|
||||||
expection.fulfill()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
AbstractSocketTest.socket.connect()
|
|
||||||
XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connecting)
|
|
||||||
waitForExpectationsWithTimeout(AbstractSocketTest.TEST_TIMEOUT, handler: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func generateTestName(rawTestName:String) ->String {
|
|
||||||
return rawTestName + testKind!.rawValue
|
|
||||||
}
|
|
||||||
|
|
||||||
func checkConnectionStatus() {
|
|
||||||
XCTAssertEqual(AbstractSocketTest.socket.status, SocketIOClientStatus.Connected)
|
|
||||||
XCTAssertFalse(AbstractSocketTest.socket.secure)
|
|
||||||
}
|
|
||||||
|
|
||||||
func socketMultipleEmit(testName:String, emitData:Array<AnyObject>, callback:NormalCallback){
|
|
||||||
let finalTestname = generateTestName(testName)
|
|
||||||
weak var expection = self.expectationWithDescription(finalTestname)
|
|
||||||
func didGetEmit(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
callback(result, ack)
|
|
||||||
if let expection = expection {
|
|
||||||
expection.fulfill()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractSocketTest.socket.emit(finalTestname, withItems: emitData)
|
|
||||||
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)
|
|
||||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func socketEmit(testName:String, emitData:AnyObject?, callback:NormalCallback){
|
|
||||||
let finalTestname = generateTestName(testName)
|
|
||||||
weak var expection = self.expectationWithDescription(finalTestname)
|
|
||||||
func didGetEmit(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
callback(result, ack)
|
|
||||||
if let expection = expection {
|
|
||||||
expection.fulfill()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractSocketTest.socket.on(finalTestname + "Return", callback: didGetEmit)
|
|
||||||
if let emitData = emitData {
|
|
||||||
AbstractSocketTest.socket.emit(finalTestname, emitData)
|
|
||||||
} else {
|
|
||||||
AbstractSocketTest.socket.emit(finalTestname)
|
|
||||||
}
|
|
||||||
|
|
||||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
func socketAcknwoledgeMultiple(testName:String, Data:Array<AnyObject>, callback:NormalCallback){
|
|
||||||
let finalTestname = generateTestName(testName)
|
|
||||||
weak var expection = self.expectationWithDescription(finalTestname)
|
|
||||||
func didGetResult(result: [AnyObject]) {
|
|
||||||
callback(result, SocketAckEmitter(socket: AbstractSocketTest.socket, ackNum: -1))
|
|
||||||
if let expection = expection {
|
|
||||||
expection.fulfill()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
AbstractSocketTest.socket.emitWithAck(finalTestname, withItems: Data)(timeoutAfter: 5, callback: didGetResult)
|
|
||||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
func socketAcknwoledge(testName:String, Data:AnyObject?, callback:NormalCallback){
|
|
||||||
let finalTestname = generateTestName(testName)
|
|
||||||
weak var expection = self.expectationWithDescription(finalTestname)
|
|
||||||
func didGet(result:[AnyObject]) {
|
|
||||||
callback(result, SocketAckEmitter(socket: AbstractSocketTest.socket, ackNum: -1))
|
|
||||||
if let expection = expection {
|
|
||||||
expection.fulfill()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var ack:OnAckCallback!
|
|
||||||
if let Data = Data {
|
|
||||||
ack = AbstractSocketTest.socket.emitWithAck(finalTestname, Data)
|
|
||||||
} else {
|
|
||||||
ack = AbstractSocketTest.socket.emitWithAck(finalTestname)
|
|
||||||
}
|
|
||||||
ack(timeoutAfter: 20, callback: didGet)
|
|
||||||
|
|
||||||
waitForExpectationsWithTimeout(SocketEmitTest.TEST_TIMEOUT, handler: nil)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,88 +0,0 @@
|
|||||||
//
|
|
||||||
// SocketAcknowledgementTest.swift
|
|
||||||
// Socket.IO-Client-Swift
|
|
||||||
//
|
|
||||||
// Created by Lukas Schmidt on 27.07.15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
class SocketAcknowledgementTest: AbstractSocketTest {
|
|
||||||
|
|
||||||
override func setUp() {
|
|
||||||
super.setUp()
|
|
||||||
testKind = TestKind.Acknowledgement
|
|
||||||
if AbstractSocketTest.socket == nil {
|
|
||||||
AbstractSocketTest.socket = SocketIOClient(socketURL: "milkbartube.com:6979", opts: [
|
|
||||||
"reconnects": true, // default true
|
|
||||||
"reconnectAttempts": -1, // default -1
|
|
||||||
"reconnectWait": 5, // default 10
|
|
||||||
"forcePolling": false,
|
|
||||||
"forceWebsockets": false,// default false
|
|
||||||
"path": ""])
|
|
||||||
openConnection()
|
|
||||||
}else {
|
|
||||||
AbstractSocketTest.socket.leaveNamespace()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func testConnectionStatus() {
|
|
||||||
super.checkConnectionStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBasic() {
|
|
||||||
SocketTestCases.testBasic(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testNull() {
|
|
||||||
SocketTestCases.testNull(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBinary() {
|
|
||||||
SocketTestCases.testBinary(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testArray() {
|
|
||||||
SocketTestCases.testArray(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testString() {
|
|
||||||
SocketTestCases.testString(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBool() {
|
|
||||||
SocketTestCases.testBool(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testInteger() {
|
|
||||||
SocketTestCases.testInteger(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testDouble() {
|
|
||||||
SocketTestCases.testDouble(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSON() {
|
|
||||||
SocketTestCases.testJSON(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSONWithBuffer() {
|
|
||||||
SocketTestCases.testJSONWithBuffer(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testUnicode() {
|
|
||||||
SocketTestCases.testUnicode(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleItems() {
|
|
||||||
SocketTestCases.testMultipleItems(socketAcknwoledgeMultiple)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleWithBuffer() {
|
|
||||||
SocketTestCases.testMultipleItemsWithBuffer(socketAcknwoledgeMultiple)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,93 +0,0 @@
|
|||||||
//
|
|
||||||
// ConvertedSocketTest.swift
|
|
||||||
// Socket.IO-Client-Swift
|
|
||||||
//
|
|
||||||
// Created by Lukas Schmidt on 25.07.15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import XCTest
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
class SocketEmitTest: AbstractSocketTest {
|
|
||||||
override func setUp() {
|
|
||||||
super.setUp()
|
|
||||||
testKind = TestKind.Emit
|
|
||||||
if AbstractSocketTest.socket == nil {
|
|
||||||
AbstractSocketTest.socket = SocketIOClient(socketURL: AbstractSocketTest.serverURL, opts: [
|
|
||||||
"reconnects": true, // default true
|
|
||||||
"reconnectAttempts": -1, // default -1
|
|
||||||
"reconnectWait": 5, // default 10
|
|
||||||
"forcePolling": false,
|
|
||||||
"forceWebsockets": false,// default false
|
|
||||||
"path": ""]
|
|
||||||
)
|
|
||||||
openConnection()
|
|
||||||
}else {
|
|
||||||
AbstractSocketTest.socket.leaveNamespace()
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
override func tearDown() {
|
|
||||||
super.tearDown()
|
|
||||||
}
|
|
||||||
|
|
||||||
func testConnectionStatus() {
|
|
||||||
super.checkConnectionStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBasic() {
|
|
||||||
SocketTestCases.testBasic(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testNull() {
|
|
||||||
SocketTestCases.testNull(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBinary() {
|
|
||||||
SocketTestCases.testBinary(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testArray() {
|
|
||||||
SocketTestCases.testArray(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testString() {
|
|
||||||
SocketTestCases.testString(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBool() {
|
|
||||||
SocketTestCases.testBool(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testInteger() {
|
|
||||||
SocketTestCases.testInteger(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testDouble() {
|
|
||||||
SocketTestCases.testDouble(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSON() {
|
|
||||||
SocketTestCases.testJSON(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSONWithBuffer() {
|
|
||||||
SocketTestCases.testJSONWithBuffer(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testUnicode() {
|
|
||||||
SocketTestCases.testUnicode(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleItems() {
|
|
||||||
SocketTestCases.testMultipleItems(socketMultipleEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleWithBuffer() {
|
|
||||||
SocketTestCases.testMultipleItemsWithBuffer(socketMultipleEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,88 +0,0 @@
|
|||||||
//
|
|
||||||
// SocketNamespaceAcknowledgementTest.swift
|
|
||||||
// Socket.IO-Client-Swift
|
|
||||||
//
|
|
||||||
// Created by Lukas Schmidt on 28.07.15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
class SocketNamespaceAcknowledgementTest: AbstractSocketTest {
|
|
||||||
|
|
||||||
override func setUp() {
|
|
||||||
super.setUp()
|
|
||||||
testKind = TestKind.Acknowledgement
|
|
||||||
if AbstractSocketTest.socket == nil {
|
|
||||||
AbstractSocketTest.socket = SocketIOClient(socketURL: AbstractSocketTest.serverURL, opts: [
|
|
||||||
"reconnects": true, // default true
|
|
||||||
"reconnectAttempts": -1, // default -1
|
|
||||||
"reconnectWait": 5, // default 10
|
|
||||||
"forcePolling": false,
|
|
||||||
"forceWebsockets": false,// default false
|
|
||||||
"path": "",
|
|
||||||
"nsp": "/swift"])
|
|
||||||
openConnection()
|
|
||||||
}else {
|
|
||||||
AbstractSocketTest.socket.joinNamespace("/swift")
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func testConnectionStatus() {
|
|
||||||
super.checkConnectionStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBasic() {
|
|
||||||
SocketTestCases.testBasic(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testNull() {
|
|
||||||
SocketTestCases.testNull(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBinary() {
|
|
||||||
SocketTestCases.testBinary(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testArray() {
|
|
||||||
SocketTestCases.testArray(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testString() {
|
|
||||||
SocketTestCases.testString(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBool() {
|
|
||||||
SocketTestCases.testBool(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testInteger() {
|
|
||||||
SocketTestCases.testInteger(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testDouble() {
|
|
||||||
SocketTestCases.testDouble(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSON() {
|
|
||||||
SocketTestCases.testJSON(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSONWithBuffer() {
|
|
||||||
SocketTestCases.testJSONWithBuffer(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testUnicode() {
|
|
||||||
SocketTestCases.testUnicode(socketAcknwoledge)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleItems() {
|
|
||||||
SocketTestCases.testMultipleItems(socketAcknwoledgeMultiple)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleWithBuffer() {
|
|
||||||
SocketTestCases.testMultipleItemsWithBuffer(socketAcknwoledgeMultiple)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,87 +0,0 @@
|
|||||||
//
|
|
||||||
// SocketNamespaceEmitTest.swift
|
|
||||||
// Socket.IO-Client-Swift
|
|
||||||
//
|
|
||||||
// Created by Lukas Schmidt on 26.07.15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import XCTest
|
|
||||||
|
|
||||||
class SocketNamespaceEmitTest: AbstractSocketTest {
|
|
||||||
|
|
||||||
override func setUp() {
|
|
||||||
super.setUp()
|
|
||||||
testKind = TestKind.Emit
|
|
||||||
if AbstractSocketTest.socket == nil {
|
|
||||||
AbstractSocketTest.socket = SocketIOClient(socketURL: AbstractSocketTest.serverURL, opts: [
|
|
||||||
"reconnects": true, // default true
|
|
||||||
"reconnectAttempts": -1, // default -1
|
|
||||||
"reconnectWait": 5, // default 10
|
|
||||||
"forcePolling": false,
|
|
||||||
"forceWebsockets": false,// default false
|
|
||||||
"path": "",
|
|
||||||
"nsp": "/swift"])
|
|
||||||
openConnection()
|
|
||||||
}else {
|
|
||||||
AbstractSocketTest.socket.joinNamespace("/swift")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func testConnectionStatus() {
|
|
||||||
super.checkConnectionStatus()
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBasic() {
|
|
||||||
SocketTestCases.testBasic(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testNull() {
|
|
||||||
SocketTestCases.testNull(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBinary() {
|
|
||||||
SocketTestCases.testBinary(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testArray() {
|
|
||||||
SocketTestCases.testArray(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testString() {
|
|
||||||
SocketTestCases.testString(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testBool() {
|
|
||||||
SocketTestCases.testBool(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testInteger() {
|
|
||||||
SocketTestCases.testInteger(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testDouble() {
|
|
||||||
SocketTestCases.testDouble(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSON() {
|
|
||||||
SocketTestCases.testJSON(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testJSONWithBuffer() {
|
|
||||||
SocketTestCases.testJSONWithBuffer(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testUnicode() {
|
|
||||||
SocketTestCases.testUnicode(socketEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleItems() {
|
|
||||||
SocketTestCases.testMultipleItems(socketMultipleEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
func testMultipleWithBuffer() {
|
|
||||||
SocketTestCases.testMultipleItemsWithBuffer(socketMultipleEmit)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -13,6 +13,8 @@ class SocketParserTest: XCTestCase {
|
|||||||
//Format key: message; namespace-data-binary-id
|
//Format key: message; namespace-data-binary-id
|
||||||
static let packetTypes: Dictionary<String, (String, [AnyObject], [NSData], Int)> = [
|
static let packetTypes: Dictionary<String, (String, [AnyObject], [NSData], Int)> = [
|
||||||
"0": ("/", [], [], -1), "1": ("/", [], [], -1),
|
"0": ("/", [], [], -1), "1": ("/", [], [], -1),
|
||||||
|
"25[\"test\"]": ("/", ["test"], [], 5),
|
||||||
|
"2[\"test\",\"~~0\"]": ("/", ["test", "~~0"], [], -1),
|
||||||
"2/swift,[\"testArrayEmitReturn\",[\"test3\",\"test4\"]]": ("/swift", ["testArrayEmitReturn", ["test3", "test4"]], [], -1),
|
"2/swift,[\"testArrayEmitReturn\",[\"test3\",\"test4\"]]": ("/swift", ["testArrayEmitReturn", ["test3", "test4"]], [], -1),
|
||||||
"51-/swift,[\"testMultipleItemsWithBufferEmitReturn\",[1,2],{\"test\":\"bob\"},25,\"polo\",{\"_placeholder\":true,\"num\":0}]": ("/swift", ["testMultipleItemsWithBufferEmitReturn", [1, 2], ["test": "bob"], 25, "polo", "~~0"], [], -1),
|
"51-/swift,[\"testMultipleItemsWithBufferEmitReturn\",[1,2],{\"test\":\"bob\"},25,\"polo\",{\"_placeholder\":true,\"num\":0}]": ("/swift", ["testMultipleItemsWithBufferEmitReturn", [1, 2], ["test": "bob"], 25, "polo", "~~0"], [], -1),
|
||||||
"3/swift,0[[\"test3\",\"test4\"]]": ("/swift", [["test3", "test4"]], [], 0),
|
"3/swift,0[[\"test3\",\"test4\"]]": ("/swift", [["test3", "test4"]], [], 0),
|
||||||
@ -43,6 +45,16 @@ class SocketParserTest: XCTestCase {
|
|||||||
validateParseResult(message)
|
validateParseResult(message)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func testIdEvent() {
|
||||||
|
let message = "25[\"test\"]"
|
||||||
|
validateParseResult(message)
|
||||||
|
}
|
||||||
|
|
||||||
|
func testBinaryPlaceholderAsString() {
|
||||||
|
let message = "2[\"test\",\"~~0\"]"
|
||||||
|
validateParseResult(message)
|
||||||
|
}
|
||||||
|
|
||||||
func testNameSpaceArrayParse() {
|
func testNameSpaceArrayParse() {
|
||||||
let message = "2/swift,[\"testArrayEmitReturn\",[\"test3\",\"test4\"]]"
|
let message = "2/swift,[\"testArrayEmitReturn\",[\"test3\",\"test4\"]]"
|
||||||
validateParseResult(message)
|
validateParseResult(message)
|
||||||
|
|||||||
@ -1,248 +0,0 @@
|
|||||||
//
|
|
||||||
// SocketTestCases.swift
|
|
||||||
// Socket.IO-Client-Swift
|
|
||||||
//
|
|
||||||
// Created by Lukas Schmidt on 02.08.15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import XCTest
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
class SocketTestCases: NSObject {
|
|
||||||
typealias SocketSendFunction = (testName:String, emitData:AnyObject?, callback:NormalCallback)->()
|
|
||||||
|
|
||||||
static func testBasic(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "basicTest"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: nil, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testNull(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testNull"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let _ = result.first as? NSNull {
|
|
||||||
|
|
||||||
}else
|
|
||||||
{
|
|
||||||
XCTFail("Should have NSNull as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: NSNull(), callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testBinary(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testBinary"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let data = result.first as? NSData {
|
|
||||||
let string = NSString(data: data, encoding: NSUTF8StringEncoding)!
|
|
||||||
XCTAssertEqual(string, "gakgakgak2")
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSData as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let data = NSString(string: "gakgakgak2").dataUsingEncoding(NSUTF8StringEncoding)!
|
|
||||||
abstractSocketSend(testName: testName, emitData: data, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testArray(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testArray"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let array = result.first as? NSArray {
|
|
||||||
XCTAssertEqual(array.count, 2)
|
|
||||||
XCTAssertEqual((array.firstObject! as! String), "test3")
|
|
||||||
XCTAssertEqual((array.lastObject! as! String), "test4")
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSArray as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: ["test1", "test2"], callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testString(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testString"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let string = result.first as? String {
|
|
||||||
XCTAssertEqual(string, "polo")
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have String as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: "marco", callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testBool(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testBool"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let bool = result.first as? NSNumber {
|
|
||||||
XCTAssertTrue(bool.boolValue)
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Boolean as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: false, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testInteger(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testInteger"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let integer = result.first as? Int {
|
|
||||||
XCTAssertEqual(integer, 20)
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Integer as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: 10, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testDouble(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testDouble"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let double = result.first as? NSNumber {
|
|
||||||
XCTAssertEqual(double.floatValue, 1.2)
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Double as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: 1.1, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testJSONWithBuffer(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testJSONWithBuffer"
|
|
||||||
let data = "0".dataUsingEncoding(NSUTF8StringEncoding, allowLossyConversion: false)!
|
|
||||||
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let json = result.first as? NSDictionary {
|
|
||||||
XCTAssertEqual((json.valueForKey("testString")! as! String), "test")
|
|
||||||
XCTAssertEqual((json.valueForKey("testNumber")! as! Int), 15)
|
|
||||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).count, 2)
|
|
||||||
XCTAssertEqual(((json.valueForKey("testArray")! as! Array<AnyObject>).last! as! Int), 1)
|
|
||||||
let string = NSString(data: (json.valueForKey("testArray")! as! Array<AnyObject>).first! as! NSData, encoding: NSUTF8StringEncoding)!
|
|
||||||
XCTAssertEqual(string, "gakgakgak2")
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSDictionary as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15, "buf": data]
|
|
||||||
|
|
||||||
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testJSON(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testJSON"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let json = result.first as? NSDictionary {
|
|
||||||
XCTAssertEqual((json.valueForKey("testString")! as! String), "test")
|
|
||||||
XCTAssertEqual(json.valueForKey("testNumber")! as? Int, 15)
|
|
||||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).count, 2)
|
|
||||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).first! as? Int, 1)
|
|
||||||
XCTAssertEqual((json.valueForKey("testArray")! as! Array<AnyObject>).last! as? Int, 1)
|
|
||||||
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSDictionary as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let json = ["name": "test", "testArray": ["hallo"], "nestedTest": ["test": "test"], "number": 15]
|
|
||||||
|
|
||||||
abstractSocketSend(testName: testName, emitData: json, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testUnicode(abstractSocketSend:SocketSendFunction) {
|
|
||||||
let testName = "testUnicode"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
if let unicode = result.first as? String {
|
|
||||||
XCTAssertEqual(unicode, "🚄")
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have String as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
abstractSocketSend(testName: testName, emitData: "🚀", callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testMultipleItemsWithBuffer(abstractSocketMultipleSend:(testName:String, emitData:Array<AnyObject>, callback:NormalCallback)->()) {
|
|
||||||
let testName = "testMultipleItemsWithBuffer"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
XCTAssertEqual(result.count, 5)
|
|
||||||
if result.count != 5 {
|
|
||||||
XCTFail("Fatal Fail. Lost some Data")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if let array = result.first as? Array<AnyObject> {
|
|
||||||
XCTAssertEqual((array.last! as! Int), 2)
|
|
||||||
XCTAssertEqual((array.first! as! Int), 1)
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Array as result")
|
|
||||||
}
|
|
||||||
if let dict = result[1] as? NSDictionary {
|
|
||||||
XCTAssertEqual((dict.valueForKey("test") as! String), "bob")
|
|
||||||
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSDictionary as result")
|
|
||||||
}
|
|
||||||
if let number = result[2] as? Int {
|
|
||||||
XCTAssertEqual(number, 25)
|
|
||||||
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Integer as result")
|
|
||||||
}
|
|
||||||
if let string = result[3] as? String {
|
|
||||||
XCTAssertEqual(string, "polo")
|
|
||||||
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Integer as result")
|
|
||||||
}
|
|
||||||
if let data = result[4] as? NSData {
|
|
||||||
let string = NSString(data: data, encoding: NSUTF8StringEncoding)!
|
|
||||||
XCTAssertEqual(string, "gakgakgak2")
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSData as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let data = NSString(string: "gakgakgak2").dataUsingEncoding(NSUTF8StringEncoding)!
|
|
||||||
let emitArray = [["test1", "test2"], ["test": "test"], 15, "marco", data]
|
|
||||||
abstractSocketMultipleSend(testName: testName, emitData: emitArray, callback: didGetResult)
|
|
||||||
}
|
|
||||||
|
|
||||||
static func testMultipleItems(abstractSocketMultipleSend:(testName:String, emitData:Array<AnyObject>, callback:NormalCallback)->()) {
|
|
||||||
let testName = "testMultipleItems"
|
|
||||||
func didGetResult(result:[AnyObject], ack:SocketAckEmitter?) {
|
|
||||||
XCTAssertEqual(result.count, 5)
|
|
||||||
if result.count != 5 {
|
|
||||||
XCTFail("Fatal Fail. Lost some Data")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if let array = result.first as? Array<AnyObject> {
|
|
||||||
XCTAssertEqual((array.last! as! Int), 2)
|
|
||||||
XCTAssertEqual((array.first! as! Int), 1)
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Array as result")
|
|
||||||
}
|
|
||||||
if let dict = result[1] as? NSDictionary {
|
|
||||||
XCTAssertEqual((dict.valueForKey("test") as! String), "bob")
|
|
||||||
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSDictionary as result")
|
|
||||||
}
|
|
||||||
if let number = result[2] as? Int {
|
|
||||||
XCTAssertEqual(number, 25)
|
|
||||||
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Integer as result")
|
|
||||||
}
|
|
||||||
if let string = result[3] as? String {
|
|
||||||
XCTAssertEqual(string, "polo")
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have Integer as result")
|
|
||||||
}
|
|
||||||
if let bool = result[4] as? NSNumber {
|
|
||||||
XCTAssertFalse(bool.boolValue)
|
|
||||||
}else {
|
|
||||||
XCTFail("Should have NSNumber as result")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let emitArray = [["test1", "test2"], ["test": "test"], 15, "marco", false]
|
|
||||||
abstractSocketMultipleSend(testName: testName, emitData: emitArray, callback: didGetResult)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
//
|
|
||||||
// TestKind.swift
|
|
||||||
// Socket.IO-Client-Swift
|
|
||||||
//
|
|
||||||
// Created by Lukas Schmidt on 28.07.15.
|
|
||||||
//
|
|
||||||
//
|
|
||||||
|
|
||||||
import Foundation
|
|
||||||
|
|
||||||
enum TestKind: String {
|
|
||||||
case Emit, Acknowledgement
|
|
||||||
}
|
|
||||||
@ -24,8 +24,17 @@
|
|||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public final class SocketEngine: NSObject, WebSocketDelegate {
|
public final class SocketEngine: NSObject, SocketEngineSpec, WebSocketDelegate {
|
||||||
private typealias Probe = (msg: String, type: PacketType, data: [NSData]?)
|
public private(set) var sid = ""
|
||||||
|
public private(set) var cookies: [NSHTTPCookie]?
|
||||||
|
public private(set) var socketPath = ""
|
||||||
|
public private(set) var urlPolling = ""
|
||||||
|
public private(set) var urlWebSocket = ""
|
||||||
|
public private(set) var ws: WebSocket?
|
||||||
|
|
||||||
|
public weak var client: SocketEngineClient?
|
||||||
|
|
||||||
|
private typealias Probe = (msg: String, type: SocketEnginePacketType, data: [NSData]?)
|
||||||
private typealias ProbeWaitQueue = [Probe]
|
private typealias ProbeWaitQueue = [Probe]
|
||||||
|
|
||||||
private let allowedCharacterSet = NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
private let allowedCharacterSet = NSCharacterSet(charactersInString: "!*'();:@&=+$,/?%#[]\" {}").invertedSet
|
||||||
@ -62,27 +71,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
private(set) var polling = true
|
private(set) var polling = true
|
||||||
private(set) var websocket = false
|
private(set) var websocket = false
|
||||||
|
|
||||||
weak var client: SocketEngineClient?
|
|
||||||
var cookies: [NSHTTPCookie]?
|
|
||||||
var sid = ""
|
|
||||||
var socketPath = ""
|
|
||||||
var urlPolling = ""
|
|
||||||
var urlWebSocket = ""
|
|
||||||
|
|
||||||
var ws: WebSocket?
|
|
||||||
|
|
||||||
@objc public enum PacketType: Int {
|
|
||||||
case Open, Close, Ping, Pong, Message, Upgrade, Noop
|
|
||||||
|
|
||||||
init?(str: String) {
|
|
||||||
if let value = Int(str), raw = PacketType(rawValue: value) {
|
|
||||||
self = raw
|
|
||||||
} else {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public init(client: SocketEngineClient, sessionDelegate: NSURLSessionDelegate?) {
|
public init(client: SocketEngineClient, sessionDelegate: NSURLSessionDelegate?) {
|
||||||
self.client = client
|
self.client = client
|
||||||
self.session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration(),
|
self.session = NSURLSession(configuration: NSURLSessionConfiguration.defaultSessionConfiguration(),
|
||||||
@ -103,13 +91,13 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
closed = true
|
closed = true
|
||||||
stopPolling()
|
stopPolling()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func checkIfMessageIsBase64Binary(var message: String) {
|
private func checkIfMessageIsBase64Binary(var message: String) {
|
||||||
if message.hasPrefix("b4") {
|
if message.hasPrefix("b4") {
|
||||||
// binary in base64 string
|
// binary in base64 string
|
||||||
message.removeRange(Range<String.Index>(start: message.startIndex,
|
message.removeRange(Range<String.Index>(start: message.startIndex,
|
||||||
end: message.startIndex.advancedBy(2)))
|
end: message.startIndex.advancedBy(2)))
|
||||||
|
|
||||||
if let data = NSData(base64EncodedString: message,
|
if let data = NSData(base64EncodedString: message,
|
||||||
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters) {
|
options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters) {
|
||||||
client?.parseBinaryData(data)
|
client?.parseBinaryData(data)
|
||||||
@ -126,7 +114,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
ws?.disconnect()
|
ws?.disconnect()
|
||||||
|
|
||||||
if fast || polling {
|
if fast || polling {
|
||||||
write("", withType: PacketType.Close, withData: nil)
|
write("", withType: .Close, withData: nil)
|
||||||
client?.engineDidClose("Disconnect")
|
client?.engineDidClose("Disconnect")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,14 +131,13 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
|
|
||||||
return .Left(mutData)
|
return .Left(mutData)
|
||||||
} else {
|
} else {
|
||||||
var str = "b4"
|
let str = "b4" + data.base64EncodedStringWithOptions(
|
||||||
str += data.base64EncodedStringWithOptions(
|
|
||||||
NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
|
NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
|
||||||
|
|
||||||
return .Right(str)
|
return .Right(str)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createURLs(params: [String: AnyObject]?) -> (String, String) {
|
private func createURLs(params: [String: AnyObject]?) -> (String, String) {
|
||||||
if client == nil {
|
if client == nil {
|
||||||
return ("", "")
|
return ("", "")
|
||||||
@ -193,22 +180,22 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
|
|
||||||
private func createWebsocketAndConnect(connect: Bool) {
|
private func createWebsocketAndConnect(connect: Bool) {
|
||||||
let wsUrl = urlWebSocket + (sid == "" ? "" : "&sid=\(sid)")
|
let wsUrl = urlWebSocket + (sid == "" ? "" : "&sid=\(sid)")
|
||||||
|
|
||||||
ws = WebSocket(url: NSURL(string: wsUrl)!)
|
ws = WebSocket(url: NSURL(string: wsUrl)!)
|
||||||
|
|
||||||
if cookies != nil {
|
if cookies != nil {
|
||||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||||
for (key, value) in headers {
|
for (key, value) in headers {
|
||||||
ws?.headers[key] = value
|
ws?.headers[key] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if extraHeaders != nil {
|
if extraHeaders != nil {
|
||||||
for (headerName, value) in extraHeaders! {
|
for (headerName, value) in extraHeaders! {
|
||||||
ws?.headers[headerName] = value
|
ws?.headers[headerName] = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ws?.queue = handleQueue
|
ws?.queue = handleQueue
|
||||||
ws?.delegate = self
|
ws?.delegate = self
|
||||||
|
|
||||||
@ -223,7 +210,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
"we'll probably disconnect soon. You should report this.", type: logType)
|
"we'll probably disconnect soon. You should report this.", type: logType)
|
||||||
}
|
}
|
||||||
|
|
||||||
sendWebSocketMessage("", withType: PacketType.Upgrade, datas: nil)
|
sendWebSocketMessage("", withType: .Upgrade, datas: nil)
|
||||||
websocket = true
|
websocket = true
|
||||||
polling = false
|
polling = false
|
||||||
fastUpgrade = false
|
fastUpgrade = false
|
||||||
@ -231,71 +218,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
flushProbeWait()
|
flushProbeWait()
|
||||||
}
|
}
|
||||||
|
|
||||||
private func doPoll() {
|
|
||||||
if websocket || waitingForPoll || !connected || closed {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
waitingForPoll = true
|
|
||||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)&b64=1")!)
|
|
||||||
|
|
||||||
if cookies != nil {
|
|
||||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
|
||||||
req.allHTTPHeaderFields = headers
|
|
||||||
}
|
|
||||||
|
|
||||||
if extraHeaders != nil {
|
|
||||||
for (headerName, value) in extraHeaders! {
|
|
||||||
req.setValue(value, forHTTPHeaderField: headerName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
doLongPoll(req)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func doRequest(req: NSMutableURLRequest,
|
|
||||||
withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) {
|
|
||||||
if !polling || closed || invalidated {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.log("Doing polling request", type: logType)
|
|
||||||
|
|
||||||
req.cachePolicy = .ReloadIgnoringLocalAndRemoteCacheData
|
|
||||||
session.dataTaskWithRequest(req, completionHandler: callback).resume()
|
|
||||||
}
|
|
||||||
|
|
||||||
private func doLongPoll(req: NSMutableURLRequest) {
|
|
||||||
doRequest(req) {[weak self] data, res, err in
|
|
||||||
if let this = self {
|
|
||||||
if err != nil || data == nil {
|
|
||||||
if this.polling {
|
|
||||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
|
||||||
} else {
|
|
||||||
Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
Logger.log("Got polling response", type: this.logType)
|
|
||||||
|
|
||||||
if let str = NSString(data: data!, encoding: NSUTF8StringEncoding) as? String {
|
|
||||||
dispatch_async(this.parseQueue) {[weak this] in
|
|
||||||
this?.parsePollingMessage(str)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.waitingForPoll = false
|
|
||||||
|
|
||||||
if this.fastUpgrade {
|
|
||||||
this.doFastUpgrade()
|
|
||||||
} else if !this.closed && this.polling {
|
|
||||||
this.doPoll()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func flushProbeWait() {
|
private func flushProbeWait() {
|
||||||
Logger.log("Flushing probe wait", type: logType)
|
Logger.log("Flushing probe wait", type: logType)
|
||||||
|
|
||||||
@ -314,78 +236,6 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func flushWaitingForPost() {
|
|
||||||
if postWait.count == 0 || !connected {
|
|
||||||
return
|
|
||||||
} else if websocket {
|
|
||||||
flushWaitingForPostToWebSocket()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var postStr = ""
|
|
||||||
|
|
||||||
for packet in postWait {
|
|
||||||
let len = packet.characters.count
|
|
||||||
|
|
||||||
postStr += "\(len):\(packet)"
|
|
||||||
}
|
|
||||||
|
|
||||||
postWait.removeAll(keepCapacity: false)
|
|
||||||
|
|
||||||
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)")!)
|
|
||||||
|
|
||||||
if let cookies = cookies {
|
|
||||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies)
|
|
||||||
req.allHTTPHeaderFields = headers
|
|
||||||
}
|
|
||||||
|
|
||||||
req.HTTPMethod = "POST"
|
|
||||||
req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type")
|
|
||||||
|
|
||||||
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding,
|
|
||||||
allowLossyConversion: false)!
|
|
||||||
|
|
||||||
req.HTTPBody = postData
|
|
||||||
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
|
||||||
|
|
||||||
waitingForPost = true
|
|
||||||
|
|
||||||
Logger.log("POSTing: %@", type: logType, args: postStr)
|
|
||||||
|
|
||||||
doRequest(req) {[weak self] data, res, err in
|
|
||||||
if let this = self {
|
|
||||||
if err != nil && this.polling {
|
|
||||||
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
|
||||||
return
|
|
||||||
} else if err != nil {
|
|
||||||
Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
this.waitingForPost = false
|
|
||||||
|
|
||||||
dispatch_async(this.emitQueue) {[weak this] in
|
|
||||||
if !(this?.fastUpgrade ?? true) {
|
|
||||||
this?.flushWaitingForPost()
|
|
||||||
this?.doPoll()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// We had packets waiting for send when we upgraded
|
|
||||||
// Send them raw
|
|
||||||
private func flushWaitingForPostToWebSocket() {
|
|
||||||
guard let ws = self.ws else {return}
|
|
||||||
|
|
||||||
for msg in postWait {
|
|
||||||
ws.writeString(msg)
|
|
||||||
}
|
|
||||||
|
|
||||||
postWait.removeAll(keepCapacity: true)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func handleClose() {
|
private func handleClose() {
|
||||||
if let client = client where polling == true {
|
if let client = client where polling == true {
|
||||||
client.engineDidClose("Disconnect")
|
client.engineDidClose("Disconnect")
|
||||||
@ -410,18 +260,18 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
|
|
||||||
self.sid = sid
|
self.sid = sid
|
||||||
connected = true
|
connected = true
|
||||||
|
|
||||||
if let upgrades = json?["upgrades"] as? [String] {
|
if let upgrades = json?["upgrades"] as? [String] {
|
||||||
upgradeWs = upgrades.filter {$0 == "websocket"}.count != 0
|
upgradeWs = upgrades.filter {$0 == "websocket"}.count != 0
|
||||||
} else {
|
} else {
|
||||||
upgradeWs = false
|
upgradeWs = false
|
||||||
}
|
}
|
||||||
|
|
||||||
if let pingInterval = json?["pingInterval"] as? Double, pingTimeout = json?["pingTimeout"] as? Double {
|
if let pingInterval = json?["pingInterval"] as? Double, pingTimeout = json?["pingTimeout"] as? Double {
|
||||||
self.pingInterval = pingInterval / 1000.0
|
self.pingInterval = pingInterval / 1000.0
|
||||||
self.pingTimeout = pingTimeout / 1000.0
|
self.pingTimeout = pingTimeout / 1000.0
|
||||||
}
|
}
|
||||||
|
|
||||||
if !forcePolling && !forceWebsockets && upgradeWs {
|
if !forcePolling && !forceWebsockets && upgradeWs {
|
||||||
createWebsocketAndConnect(true)
|
createWebsocketAndConnect(true)
|
||||||
}
|
}
|
||||||
@ -465,7 +315,7 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
if connected {
|
if connected {
|
||||||
Logger.error("Tried to open while connected", type: logType)
|
Logger.error("Tried to open while connected", type: logType)
|
||||||
client?.didError("Tried to open while connected")
|
client?.didError("Tried to open while connected")
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,17 +339,261 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||||
reqPolling.allHTTPHeaderFields = headers
|
reqPolling.allHTTPHeaderFields = headers
|
||||||
}
|
}
|
||||||
|
|
||||||
if let extraHeaders = extraHeaders {
|
if let extraHeaders = extraHeaders {
|
||||||
for (headerName, value) in extraHeaders {
|
for (headerName, value) in extraHeaders {
|
||||||
reqPolling.setValue(value, forHTTPHeaderField: headerName)
|
reqPolling.setValue(value, forHTTPHeaderField: headerName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
doLongPoll(reqPolling)
|
doLongPoll(reqPolling)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func parsePollingMessage(str: String) {
|
private func parseEngineData(data: NSData) {
|
||||||
|
Logger.log("Got binary data: %@", type: "SocketEngine", args: data)
|
||||||
|
client?.parseBinaryData(data.subdataWithRange(NSMakeRange(1, data.length - 1)))
|
||||||
|
}
|
||||||
|
|
||||||
|
private func parseEngineMessage(var message: String, fromPolling: Bool) {
|
||||||
|
Logger.log("Got message: %@", type: logType, args: message)
|
||||||
|
|
||||||
|
let type = SocketEnginePacketType(str: (message["^(\\d)"].groups()?[1]) ?? "") ?? {
|
||||||
|
self.checkIfMessageIsBase64Binary(message)
|
||||||
|
return .Noop
|
||||||
|
}()
|
||||||
|
|
||||||
|
if fromPolling && type != .Noop {
|
||||||
|
fixDoubleUTF8(&message)
|
||||||
|
}
|
||||||
|
|
||||||
|
switch type {
|
||||||
|
case .Message:
|
||||||
|
message.removeAtIndex(message.startIndex)
|
||||||
|
handleMessage(message)
|
||||||
|
case .Noop:
|
||||||
|
handleNOOP()
|
||||||
|
case .Pong:
|
||||||
|
handlePong(message)
|
||||||
|
case .Open:
|
||||||
|
message.removeAtIndex(message.startIndex)
|
||||||
|
handleOpen(message)
|
||||||
|
case .Close:
|
||||||
|
handleClose()
|
||||||
|
default:
|
||||||
|
Logger.log("Got unknown packet type", type: logType)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func probeWebSocket() {
|
||||||
|
if websocketConnected {
|
||||||
|
sendWebSocketMessage("probe", withType: .Ping)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Send an engine message (4)
|
||||||
|
public func send(msg: String, withData datas: [NSData]?) {
|
||||||
|
if probing {
|
||||||
|
probeWait.append((msg, .Message, datas))
|
||||||
|
} else {
|
||||||
|
write(msg, withType: .Message, withData: datas)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@objc private func sendPing() {
|
||||||
|
//Server is not responding
|
||||||
|
if pongsMissed > pongsMissedMax {
|
||||||
|
pingTimer?.invalidate()
|
||||||
|
client?.engineDidClose("Ping timeout")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
++pongsMissed
|
||||||
|
write("", withType: .Ping, withData: nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Starts the ping timer
|
||||||
|
private func startPingTimer() {
|
||||||
|
if let pingInterval = pingInterval {
|
||||||
|
pingTimer?.invalidate()
|
||||||
|
pingTimer = nil
|
||||||
|
|
||||||
|
dispatch_async(dispatch_get_main_queue()) {
|
||||||
|
self.pingTimer = NSTimer.scheduledTimerWithTimeInterval(pingInterval, target: self,
|
||||||
|
selector: Selector("sendPing"), userInfo: nil, repeats: true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private func upgradeTransport() {
|
||||||
|
if websocketConnected {
|
||||||
|
Logger.log("Upgrading transport to WebSockets", type: logType)
|
||||||
|
|
||||||
|
fastUpgrade = true
|
||||||
|
sendPollMessage("", withType: .Noop)
|
||||||
|
// After this point, we should not send anymore polling messages
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
Write a message, independent of transport.
|
||||||
|
*/
|
||||||
|
public func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData]?) {
|
||||||
|
dispatch_async(emitQueue) {
|
||||||
|
if self.connected {
|
||||||
|
if self.websocket {
|
||||||
|
Logger.log("Writing ws: %@ has data: %@", type: self.logType, args: msg,
|
||||||
|
data == nil ? false : true)
|
||||||
|
self.sendWebSocketMessage(msg, withType: type, datas: data)
|
||||||
|
} else {
|
||||||
|
Logger.log("Writing poll: %@ has data: %@", type: self.logType, args: msg,
|
||||||
|
data == nil ? false : true)
|
||||||
|
self.sendPollMessage(msg, withType: type, datas: data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Polling methods
|
||||||
|
extension SocketEngine {
|
||||||
|
func doPoll() {
|
||||||
|
if websocket || waitingForPoll || !connected || closed {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
waitingForPoll = true
|
||||||
|
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)&b64=1")!)
|
||||||
|
|
||||||
|
if cookies != nil {
|
||||||
|
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies!)
|
||||||
|
req.allHTTPHeaderFields = headers
|
||||||
|
}
|
||||||
|
|
||||||
|
if extraHeaders != nil {
|
||||||
|
for (headerName, value) in extraHeaders! {
|
||||||
|
req.setValue(value, forHTTPHeaderField: headerName)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
doLongPoll(req)
|
||||||
|
}
|
||||||
|
|
||||||
|
func doRequest(req: NSMutableURLRequest,
|
||||||
|
withCallback callback: (NSData?, NSURLResponse?, NSError?) -> Void) {
|
||||||
|
if !polling || closed || invalidated {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.log("Doing polling request", type: logType)
|
||||||
|
|
||||||
|
req.cachePolicy = .ReloadIgnoringLocalAndRemoteCacheData
|
||||||
|
session.dataTaskWithRequest(req, completionHandler: callback).resume()
|
||||||
|
}
|
||||||
|
|
||||||
|
func doLongPoll(req: NSMutableURLRequest) {
|
||||||
|
doRequest(req) {[weak self] data, res, err in
|
||||||
|
if let this = self {
|
||||||
|
if err != nil || data == nil {
|
||||||
|
if this.polling {
|
||||||
|
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||||
|
} else {
|
||||||
|
Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger.log("Got polling response", type: this.logType)
|
||||||
|
|
||||||
|
if let str = NSString(data: data!, encoding: NSUTF8StringEncoding) as? String {
|
||||||
|
dispatch_async(this.parseQueue) {[weak this] in
|
||||||
|
this?.parsePollingMessage(str)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.waitingForPoll = false
|
||||||
|
|
||||||
|
if this.fastUpgrade {
|
||||||
|
this.doFastUpgrade()
|
||||||
|
} else if !this.closed && this.polling {
|
||||||
|
this.doPoll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func flushWaitingForPost() {
|
||||||
|
if postWait.count == 0 || !connected {
|
||||||
|
return
|
||||||
|
} else if websocket {
|
||||||
|
flushWaitingForPostToWebSocket()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var postStr = ""
|
||||||
|
|
||||||
|
for packet in postWait {
|
||||||
|
let len = packet.characters.count
|
||||||
|
|
||||||
|
postStr += "\(len):\(packet)"
|
||||||
|
}
|
||||||
|
|
||||||
|
postWait.removeAll(keepCapacity: false)
|
||||||
|
|
||||||
|
let req = NSMutableURLRequest(URL: NSURL(string: urlPolling + "&sid=\(sid)")!)
|
||||||
|
|
||||||
|
if let cookies = cookies {
|
||||||
|
let headers = NSHTTPCookie.requestHeaderFieldsWithCookies(cookies)
|
||||||
|
req.allHTTPHeaderFields = headers
|
||||||
|
}
|
||||||
|
|
||||||
|
req.HTTPMethod = "POST"
|
||||||
|
req.setValue("text/plain; charset=UTF-8", forHTTPHeaderField: "Content-Type")
|
||||||
|
|
||||||
|
let postData = postStr.dataUsingEncoding(NSUTF8StringEncoding,
|
||||||
|
allowLossyConversion: false)!
|
||||||
|
|
||||||
|
req.HTTPBody = postData
|
||||||
|
req.setValue(String(postData.length), forHTTPHeaderField: "Content-Length")
|
||||||
|
|
||||||
|
waitingForPost = true
|
||||||
|
|
||||||
|
Logger.log("POSTing: %@", type: logType, args: postStr)
|
||||||
|
|
||||||
|
doRequest(req) {[weak self] data, res, err in
|
||||||
|
if let this = self {
|
||||||
|
if err != nil && this.polling {
|
||||||
|
this.handlePollingFailed(err?.localizedDescription ?? "Error")
|
||||||
|
return
|
||||||
|
} else if err != nil {
|
||||||
|
Logger.error(err?.localizedDescription ?? "Error", type: this.logType)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.waitingForPost = false
|
||||||
|
|
||||||
|
dispatch_async(this.emitQueue) {[weak this] in
|
||||||
|
if !(this?.fastUpgrade ?? true) {
|
||||||
|
this?.flushWaitingForPost()
|
||||||
|
this?.doPoll()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// We had packets waiting for send when we upgraded
|
||||||
|
// Send them raw
|
||||||
|
func flushWaitingForPostToWebSocket() {
|
||||||
|
guard let ws = self.ws else {return}
|
||||||
|
|
||||||
|
for msg in postWait {
|
||||||
|
ws.writeString(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
postWait.removeAll(keepCapacity: true)
|
||||||
|
}
|
||||||
|
|
||||||
|
func parsePollingMessage(str: String) {
|
||||||
guard str.characters.count != 1 else {
|
guard str.characters.count != 1 else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -521,159 +615,57 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func parseEngineData(data: NSData) {
|
|
||||||
Logger.log("Got binary data: %@", type: "SocketEngine", args: data)
|
|
||||||
client?.parseBinaryData(data.subdataWithRange(NSMakeRange(1, data.length - 1)))
|
|
||||||
}
|
|
||||||
|
|
||||||
private func parseEngineMessage(var message: String, fromPolling: Bool) {
|
|
||||||
Logger.log("Got message: %@", type: logType, args: message)
|
|
||||||
|
|
||||||
let type = PacketType(str: (message["^(\\d)"].groups()?[1]) ?? "") ?? {
|
|
||||||
self.checkIfMessageIsBase64Binary(message)
|
|
||||||
return .Noop
|
|
||||||
}()
|
|
||||||
|
|
||||||
|
|
||||||
if fromPolling && type != .Noop {
|
|
||||||
fixDoubleUTF8(&message)
|
|
||||||
}
|
|
||||||
|
|
||||||
switch type {
|
|
||||||
case PacketType.Message:
|
|
||||||
message.removeAtIndex(message.startIndex)
|
|
||||||
handleMessage(message)
|
|
||||||
case PacketType.Noop:
|
|
||||||
handleNOOP()
|
|
||||||
case PacketType.Pong:
|
|
||||||
handlePong(message)
|
|
||||||
case PacketType.Open:
|
|
||||||
message.removeAtIndex(message.startIndex)
|
|
||||||
handleOpen(message)
|
|
||||||
case PacketType.Close:
|
|
||||||
handleClose()
|
|
||||||
default:
|
|
||||||
Logger.log("Got unknown packet type", type: logType)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private func probeWebSocket() {
|
|
||||||
if websocketConnected {
|
|
||||||
sendWebSocketMessage("probe", withType: PacketType.Ping)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send an engine message (4)
|
|
||||||
public func send(msg: String, withData datas: [NSData]?) {
|
|
||||||
if probing {
|
|
||||||
probeWait.append((msg, PacketType.Message, datas))
|
|
||||||
} else {
|
|
||||||
write(msg, withType: PacketType.Message, withData: datas)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@objc private func sendPing() {
|
|
||||||
//Server is not responding
|
|
||||||
if pongsMissed > pongsMissedMax {
|
|
||||||
pingTimer?.invalidate()
|
|
||||||
client?.engineDidClose("Ping timeout")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
++pongsMissed
|
|
||||||
write("", withType: PacketType.Ping, withData: nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Send polling message.
|
/// Send polling message.
|
||||||
/// Only call on emitQueue
|
/// Only call on emitQueue
|
||||||
private func sendPollMessage(var msg: String, withType type: PacketType,
|
func sendPollMessage(var msg: String, withType type: SocketEnginePacketType,
|
||||||
datas:[NSData]? = nil) {
|
datas:[NSData]? = nil) {
|
||||||
Logger.log("Sending poll: %@ as type: %@", type: logType, args: msg, type.rawValue)
|
Logger.log("Sending poll: %@ as type: %@", type: logType, args: msg, type.rawValue)
|
||||||
|
|
||||||
doubleEncodeUTF8(&msg)
|
doubleEncodeUTF8(&msg)
|
||||||
let strMsg = "\(type.rawValue)\(msg)"
|
let strMsg = "\(type.rawValue)\(msg)"
|
||||||
|
|
||||||
postWait.append(strMsg)
|
postWait.append(strMsg)
|
||||||
|
|
||||||
for data in datas ?? [] {
|
for data in datas ?? [] {
|
||||||
if case let .Right(bin) = createBinaryDataForSend(data) {
|
if case let .Right(bin) = createBinaryDataForSend(data) {
|
||||||
postWait.append(bin)
|
postWait.append(bin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !waitingForPost {
|
if !waitingForPost {
|
||||||
flushWaitingForPost()
|
flushWaitingForPost()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func stopPolling() {
|
||||||
|
invalidated = true
|
||||||
|
session.finishTasksAndInvalidate()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WebSocket methods
|
||||||
|
extension SocketEngine {
|
||||||
/// Send message on WebSockets
|
/// Send message on WebSockets
|
||||||
/// Only call on emitQueue
|
/// Only call on emitQueue
|
||||||
private func sendWebSocketMessage(str: String, withType type: PacketType,
|
private func sendWebSocketMessage(str: String, withType type: SocketEnginePacketType,
|
||||||
datas:[NSData]? = nil) {
|
datas:[NSData]? = nil) {
|
||||||
Logger.log("Sending ws: %@ as type: %@", type: logType, args: str, type.rawValue)
|
Logger.log("Sending ws: %@ as type: %@", type: logType, args: str, type.rawValue)
|
||||||
|
|
||||||
ws?.writeString("\(type.rawValue)\(str)")
|
ws?.writeString("\(type.rawValue)\(str)")
|
||||||
|
|
||||||
for data in datas ?? [] {
|
for data in datas ?? [] {
|
||||||
if case let Either.Left(bin) = createBinaryDataForSend(data) {
|
if case let Either.Left(bin) = createBinaryDataForSend(data) {
|
||||||
ws?.writeData(bin)
|
ws?.writeData(bin)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Starts the ping timer
|
|
||||||
private func startPingTimer() {
|
|
||||||
if let pingInterval = pingInterval {
|
|
||||||
pingTimer?.invalidate()
|
|
||||||
pingTimer = nil
|
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue()) {
|
|
||||||
self.pingTimer = NSTimer.scheduledTimerWithTimeInterval(pingInterval, target: self,
|
|
||||||
selector: Selector("sendPing"), userInfo: nil, repeats: true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func stopPolling() {
|
|
||||||
invalidated = true
|
|
||||||
session.finishTasksAndInvalidate()
|
|
||||||
}
|
|
||||||
|
|
||||||
private func upgradeTransport() {
|
|
||||||
if websocketConnected {
|
|
||||||
Logger.log("Upgrading transport to WebSockets", type: logType)
|
|
||||||
|
|
||||||
fastUpgrade = true
|
|
||||||
sendPollMessage("", withType: PacketType.Noop)
|
|
||||||
// After this point, we should not send anymore polling messages
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
Write a message, independent of transport.
|
|
||||||
*/
|
|
||||||
public func write(msg: String, withType type: PacketType, withData data: [NSData]?) {
|
|
||||||
dispatch_async(emitQueue) {
|
|
||||||
if self.connected {
|
|
||||||
if self.websocket {
|
|
||||||
Logger.log("Writing ws: %@ has data: %@", type: self.logType, args: msg,
|
|
||||||
data == nil ? false : true)
|
|
||||||
self.sendWebSocketMessage(msg, withType: type, datas: data)
|
|
||||||
} else {
|
|
||||||
Logger.log("Writing poll: %@ has data: %@", type: self.logType, args: msg,
|
|
||||||
data == nil ? false : true)
|
|
||||||
self.sendPollMessage(msg, withType: type, datas: data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delagate methods
|
// Delagate methods
|
||||||
|
|
||||||
public func websocketDidConnect(socket:WebSocket) {
|
public func websocketDidConnect(socket:WebSocket) {
|
||||||
websocketConnected = true
|
websocketConnected = true
|
||||||
|
|
||||||
if !forceWebsockets {
|
if !forceWebsockets {
|
||||||
probing = true
|
probing = true
|
||||||
probeWebSocket()
|
probeWebSocket()
|
||||||
@ -683,23 +675,23 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
polling = false
|
polling = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
|
public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
|
||||||
websocketConnected = false
|
websocketConnected = false
|
||||||
probing = false
|
probing = false
|
||||||
|
|
||||||
if closed {
|
if closed {
|
||||||
client?.engineDidClose("Disconnect")
|
client?.engineDidClose("Disconnect")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if websocket {
|
if websocket {
|
||||||
pingTimer?.invalidate()
|
pingTimer?.invalidate()
|
||||||
connected = false
|
connected = false
|
||||||
websocket = false
|
websocket = false
|
||||||
|
|
||||||
let reason = error?.localizedDescription ?? "Socket Disconnected"
|
let reason = error?.localizedDescription ?? "Socket Disconnected"
|
||||||
|
|
||||||
if error != nil {
|
if error != nil {
|
||||||
client?.didError(reason)
|
client?.didError(reason)
|
||||||
}
|
}
|
||||||
@ -709,11 +701,11 @@ public final class SocketEngine: NSObject, WebSocketDelegate {
|
|||||||
flushProbeWait()
|
flushProbeWait()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
|
public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
|
||||||
parseEngineMessage(text, fromPolling: false)
|
parseEngineMessage(text, fromPolling: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func websocketDidReceiveData(socket: WebSocket, data: NSData) {
|
public func websocketDidReceiveData(socket: WebSocket, data: NSData) {
|
||||||
parseEngineData(data)
|
parseEngineData(data)
|
||||||
}
|
}
|
||||||
|
|||||||
38
SocketIOClientSwift/SocketEnginePacketType.swift
Normal file
38
SocketIOClientSwift/SocketEnginePacketType.swift
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
//
|
||||||
|
// SocketEnginePacketType.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Erik Little on 10/7/15.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objc public enum SocketEnginePacketType: Int {
|
||||||
|
case Open, Close, Ping, Pong, Message, Upgrade, Noop
|
||||||
|
|
||||||
|
init?(str: String) {
|
||||||
|
if let value = Int(str), raw = SocketEnginePacketType(rawValue: value) {
|
||||||
|
self = raw
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
44
SocketIOClientSwift/SocketEngineSpec.swift
Normal file
44
SocketIOClientSwift/SocketEngineSpec.swift
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
//
|
||||||
|
// SocketEngineSpec.swift
|
||||||
|
// Socket.IO-Client-Swift
|
||||||
|
//
|
||||||
|
// Created by Erik Little on 10/7/15.
|
||||||
|
//
|
||||||
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
// of this software and associated documentation files (the "Software"), to deal
|
||||||
|
// in the Software without restriction, including without limitation the rights
|
||||||
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
// copies of the Software, and to permit persons to whom the Software is
|
||||||
|
// furnished to do so, subject to the following conditions:
|
||||||
|
//
|
||||||
|
// The above copyright notice and this permission notice shall be included in
|
||||||
|
// all copies or substantial portions of the Software.
|
||||||
|
//
|
||||||
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
|
// THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
|
import Foundation
|
||||||
|
|
||||||
|
@objc public protocol SocketEngineSpec {
|
||||||
|
weak var client: SocketEngineClient? {get set}
|
||||||
|
var cookies: [NSHTTPCookie]? {get}
|
||||||
|
var sid: String {get}
|
||||||
|
var socketPath: String {get}
|
||||||
|
var urlPolling: String {get}
|
||||||
|
var urlWebSocket: String {get}
|
||||||
|
var ws: WebSocket? {get}
|
||||||
|
|
||||||
|
init(client: SocketEngineClient, sessionDelegate: NSURLSessionDelegate?)
|
||||||
|
init(client: SocketEngineClient, opts: NSDictionary?)
|
||||||
|
|
||||||
|
func close(fast fast: Bool)
|
||||||
|
func open(opts: [String: AnyObject]?)
|
||||||
|
func send(msg: String, withData datas: [NSData]?)
|
||||||
|
func write(msg: String, withType type: SocketEnginePacketType, withData data: [NSData]?)
|
||||||
|
}
|
||||||
@ -25,12 +25,9 @@
|
|||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
public final class SocketIOClient: NSObject, SocketEngineClient {
|
public final class SocketIOClient: NSObject, SocketEngineClient {
|
||||||
private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL)
|
|
||||||
private let handleQueue: dispatch_queue_t!
|
|
||||||
|
|
||||||
public let socketURL: String
|
public let socketURL: String
|
||||||
|
|
||||||
public private(set) var engine: SocketEngine?
|
public private(set) var engine: SocketEngineSpec?
|
||||||
public private(set) var secure = false
|
public private(set) var secure = false
|
||||||
public private(set) var status = SocketIOClientStatus.NotConnected
|
public private(set) var status = SocketIOClientStatus.NotConnected
|
||||||
|
|
||||||
@ -42,18 +39,19 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
|||||||
return engine?.sid
|
return engine?.sid
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL)
|
||||||
|
private let handleQueue: dispatch_queue_t!
|
||||||
private let logType = "SocketIOClient"
|
private let logType = "SocketIOClient"
|
||||||
|
private let reconnectAttempts: Int!
|
||||||
|
|
||||||
private var anyHandler: ((SocketAnyEvent) -> Void)?
|
private var anyHandler: ((SocketAnyEvent) -> Void)?
|
||||||
private var currentReconnectAttempt = 0
|
private var currentReconnectAttempt = 0
|
||||||
private var handlers = ContiguousArray<SocketEventHandler>()
|
private var handlers = ContiguousArray<SocketEventHandler>()
|
||||||
private var connectParams: [String: AnyObject]?
|
private var connectParams: [String: AnyObject]?
|
||||||
private var reconnectTimer: NSTimer?
|
private var reconnectTimer: NSTimer?
|
||||||
|
|
||||||
private let reconnectAttempts: Int!
|
|
||||||
private var ackHandlers = SocketAckManager()
|
private var ackHandlers = SocketAckManager()
|
||||||
private var currentAck = -1
|
|
||||||
|
private(set) var currentAck = -1
|
||||||
var waitingData = [SocketPacket]()
|
var waitingData = [SocketPacket]()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -466,7 +464,6 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
|||||||
Tries to reconnect to the server.
|
Tries to reconnect to the server.
|
||||||
*/
|
*/
|
||||||
public func reconnect() {
|
public func reconnect() {
|
||||||
engine?.stopPolling()
|
|
||||||
tryReconnect()
|
tryReconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -506,3 +503,18 @@ public final class SocketIOClient: NSObject, SocketEngineClient {
|
|||||||
connect()
|
connect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Test extensions
|
||||||
|
extension SocketIOClient {
|
||||||
|
func setTestable() {
|
||||||
|
status = .Connected
|
||||||
|
}
|
||||||
|
|
||||||
|
func setTestEngine(engine: SocketEngineSpec?) {
|
||||||
|
self.engine = engine
|
||||||
|
}
|
||||||
|
|
||||||
|
func emitTest(event: String, _ data: AnyObject...) {
|
||||||
|
self._emit([event] + data)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -21,6 +21,7 @@
|
|||||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||||
// THE SOFTWARE.
|
// THE SOFTWARE.
|
||||||
|
//
|
||||||
|
|
||||||
import Foundation
|
import Foundation
|
||||||
|
|
||||||
@ -150,7 +151,7 @@ struct SocketPacket {
|
|||||||
if nsp == "/" {
|
if nsp == "/" {
|
||||||
msg = "6\(binary.count)-\(id)["
|
msg = "6\(binary.count)-\(id)["
|
||||||
} else {
|
} else {
|
||||||
msg = "6\(binary.count)-/\(nsp),\(id)["
|
msg = "6\(binary.count)-\(nsp),\(id)["
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -209,6 +210,7 @@ struct SocketPacket {
|
|||||||
mutating func fillInPlaceholders() {
|
mutating func fillInPlaceholders() {
|
||||||
for i in 0..<data.count {
|
for i in 0..<data.count {
|
||||||
if let str = data[i] as? String, num = str["~~(\\d)"].groups() {
|
if let str = data[i] as? String, num = str["~~(\\d)"].groups() {
|
||||||
|
// Fill in binary placeholder with data
|
||||||
data[i] = binary[Int(num[1])!]
|
data[i] = binary[Int(num[1])!]
|
||||||
} else if data[i] is NSDictionary || data[i] is NSArray {
|
} else if data[i] is NSDictionary || data[i] is NSArray {
|
||||||
data[i] = _fillInPlaceholders(data[i])
|
data[i] = _fillInPlaceholders(data[i])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user