Merge pull request #278 from socketio/standardize-module-name
Standardize module name
This commit is contained in:
commit
609ce08351
@ -112,13 +112,13 @@ Import the module:
|
|||||||
|
|
||||||
Swift:
|
Swift:
|
||||||
```swift
|
```swift
|
||||||
import Socket_IO_Client_Swift
|
import SocketIOClientSwift
|
||||||
```
|
```
|
||||||
|
|
||||||
Objective-C:
|
Objective-C:
|
||||||
|
|
||||||
```Objective-C
|
```Objective-C
|
||||||
#import <Socket_IO_Client_Swift/Socket_IO_Client_Swift-Swift.h>
|
#import <Socket_IO_Client_Swift/SocketIOClientSwift-Swift.h>
|
||||||
```
|
```
|
||||||
|
|
||||||
CocoaSeeds
|
CocoaSeeds
|
||||||
|
|||||||
@ -1,11 +1,12 @@
|
|||||||
Pod::Spec.new do |s|
|
Pod::Spec.new do |s|
|
||||||
s.name = "Socket.IO-Client-Swift"
|
s.name = "Socket.IO-Client-Swift"
|
||||||
|
s.module_name = "SocketIOClientSwift"
|
||||||
s.version = "5.1.0"
|
s.version = "5.1.0"
|
||||||
s.summary = "Socket.IO-client for iOS and OS X"
|
s.summary = "Socket.IO-client for iOS and OS X"
|
||||||
s.description = <<-DESC
|
s.description = <<-DESC
|
||||||
Socket.IO-client for iOS and OS X.
|
Socket.IO-client for iOS and OS X.
|
||||||
Supports ws/wss/polling connections and binary.
|
Supports ws/wss/polling connections and binary.
|
||||||
For socket.io 1.0+ and Swift 1.2.
|
For socket.io 1.0+ and Swift.
|
||||||
DESC
|
DESC
|
||||||
s.homepage = "https://github.com/socketio/socket.io-client-swift"
|
s.homepage = "https://github.com/socketio/socket.io-client-swift"
|
||||||
s.license = { :type => 'MIT' }
|
s.license = { :type => 'MIT' }
|
||||||
|
|||||||
@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
572EF21F1B51F16C00EEBB58 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */; };
|
572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.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 /* SocketIOClientSwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */; };
|
||||||
57634A111BD9B46A00E19CD7 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
57634A111BD9B46A00E19CD7 /* SocketIO-iOS.h in Headers */ = {isa = PBXBuildFile; fileRef = 572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||||
57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
57634A231BD9B46D00E19CD7 /* SocketSideEffectTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7472C65E1BCAC46E003CA70D /* SocketSideEffectTest.swift */; };
|
||||||
57634A2A1BD9B46D00E19CD7 /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; };
|
57634A2A1BD9B46D00E19CD7 /* SocketEngineTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 741F39ED1BD025D80026C9CC /* SocketEngineTest.swift */; };
|
||||||
@ -159,12 +159,12 @@
|
|||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXFileReference section */
|
/* Begin PBXFileReference section */
|
||||||
572EF2191B51F16C00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF21D1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
572EF21E1B51F16C00EEBB58 /* SocketIO-iOS.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SocketIO-iOS.h"; sourceTree = "<group>"; };
|
||||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SocketIO-iOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF22A1B51F16C00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIO.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SocketIOClientSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
572EF23B1B51F18A00EEBB58 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||||
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; };
|
||||||
@ -213,7 +213,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
572EF2251B51F16C00EEBB58 /* SocketIO.framework in Frameworks */,
|
572EF2251B51F16C00EEBB58 /* SocketIOClientSwift.framework in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -228,7 +228,7 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
572EF2431B51F18A00EEBB58 /* SocketIO.framework in Frameworks */,
|
572EF2431B51F18A00EEBB58 /* SocketIOClientSwift.framework in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
};
|
};
|
||||||
@ -265,9 +265,9 @@
|
|||||||
572EF21A1B51F16C00EEBB58 /* Products */ = {
|
572EF21A1B51F16C00EEBB58 /* Products */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
572EF2191B51F16C00EEBB58 /* SocketIO.framework */,
|
572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */,
|
||||||
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */,
|
572EF2241B51F16C00EEBB58 /* SocketIO-iOSTests.xctest */,
|
||||||
572EF2381B51F18A00EEBB58 /* SocketIO.framework */,
|
572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */,
|
||||||
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */,
|
572EF2421B51F18A00EEBB58 /* SocketIO-MacTests.xctest */,
|
||||||
57634A161BD9B46A00E19CD7 /* SocketIO.framework */,
|
57634A161BD9B46A00E19CD7 /* SocketIO.framework */,
|
||||||
57634A3B1BD9B46D00E19CD7 /* SocketIO-tvOSTests.xctest */,
|
57634A3B1BD9B46D00E19CD7 /* SocketIO-tvOSTests.xctest */,
|
||||||
@ -421,7 +421,7 @@
|
|||||||
);
|
);
|
||||||
name = "SocketIO-iOS";
|
name = "SocketIO-iOS";
|
||||||
productName = "SocketIO-iOS";
|
productName = "SocketIO-iOS";
|
||||||
productReference = 572EF2191B51F16C00EEBB58 /* SocketIO.framework */;
|
productReference = 572EF2191B51F16C00EEBB58 /* SocketIOClientSwift.framework */;
|
||||||
productType = "com.apple.product-type.framework";
|
productType = "com.apple.product-type.framework";
|
||||||
};
|
};
|
||||||
572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
572EF2231B51F16C00EEBB58 /* SocketIO-iOSTests */ = {
|
||||||
@ -457,7 +457,7 @@
|
|||||||
);
|
);
|
||||||
name = "SocketIO-Mac";
|
name = "SocketIO-Mac";
|
||||||
productName = "SocketIO-Mac";
|
productName = "SocketIO-Mac";
|
||||||
productReference = 572EF2381B51F18A00EEBB58 /* SocketIO.framework */;
|
productReference = 572EF2381B51F18A00EEBB58 /* SocketIOClientSwift.framework */;
|
||||||
productType = "com.apple.product-type.framework";
|
productType = "com.apple.product-type.framework";
|
||||||
};
|
};
|
||||||
572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
572EF2411B51F18A00EEBB58 /* SocketIO-MacTests */ = {
|
||||||
@ -798,7 +798,7 @@
|
|||||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
PRODUCT_NAME = SocketIO;
|
PRODUCT_NAME = SocketIOClientSwift;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||||
@ -813,7 +813,7 @@
|
|||||||
ENABLE_BITCODE = YES;
|
ENABLE_BITCODE = YES;
|
||||||
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
|
||||||
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
MACOSX_DEPLOYMENT_TARGET = 10.10;
|
||||||
PRODUCT_NAME = SocketIO;
|
PRODUCT_NAME = SocketIOClientSwift;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
|
||||||
TVOS_DEPLOYMENT_TARGET = 9.0;
|
TVOS_DEPLOYMENT_TARGET = 9.0;
|
||||||
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
WATCHOS_DEPLOYMENT_TARGET = 2.0;
|
||||||
@ -866,7 +866,7 @@
|
|||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
MTL_ENABLE_DEBUG_INFO = YES;
|
MTL_ENABLE_DEBUG_INFO = YES;
|
||||||
ONLY_ACTIVE_ARCH = YES;
|
ONLY_ACTIVE_ARCH = YES;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
PRODUCT_BUNDLE_IDENTIFIER = io.socket.SocketIOClientSwift;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
|
||||||
@ -916,7 +916,7 @@
|
|||||||
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
|
||||||
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
|
||||||
MTL_ENABLE_DEBUG_INFO = NO;
|
MTL_ENABLE_DEBUG_INFO = NO;
|
||||||
PRODUCT_BUNDLE_IDENTIFIER = "io.socket.$(PRODUCT_NAME:rfc1034identifier)";
|
PRODUCT_BUNDLE_IDENTIFIER = io.socket.SocketIOClientSwift;
|
||||||
SDKROOT = iphoneos;
|
SDKROOT = iphoneos;
|
||||||
SKIP_INSTALL = YES;
|
SKIP_INSTALL = YES;
|
||||||
TARGETED_DEVICE_FAMILY = "1,2";
|
TARGETED_DEVICE_FAMILY = "1,2";
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-Mac"
|
BlueprintName = "SocketIO-Mac"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-Mac"
|
BlueprintName = "SocketIO-Mac"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -79,7 +79,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-Mac"
|
BlueprintName = "SocketIO-Mac"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -97,7 +97,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
BlueprintIdentifier = "572EF2371B51F18A00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-Mac"
|
BlueprintName = "SocketIO-Mac"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-iOS"
|
BlueprintName = "SocketIO-iOS"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -58,7 +58,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-iOS"
|
BlueprintName = "SocketIO-iOS"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -80,7 +80,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-iOS"
|
BlueprintName = "SocketIO-iOS"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
@ -98,7 +98,7 @@
|
|||||||
<BuildableReference
|
<BuildableReference
|
||||||
BuildableIdentifier = "primary"
|
BuildableIdentifier = "primary"
|
||||||
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
BlueprintIdentifier = "572EF2181B51F16C00EEBB58"
|
||||||
BuildableName = "SocketIO.framework"
|
BuildableName = "SocketIOClientSwift.framework"
|
||||||
BlueprintName = "SocketIO-iOS"
|
BlueprintName = "SocketIO-iOS"
|
||||||
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
ReferencedContainer = "container:Socket.IO-Client-Swift.xcodeproj">
|
||||||
</BuildableReference>
|
</BuildableReference>
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import SocketIO
|
@testable import SocketIOClientSwift
|
||||||
|
|
||||||
class SocketAckManagerTest: XCTestCase {
|
class SocketAckManagerTest: XCTestCase {
|
||||||
var ackManager = SocketAckManager()
|
var ackManager = SocketAckManager()
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import SocketIO
|
@testable import SocketIOClientSwift
|
||||||
|
|
||||||
class SocketBasicPacketTest: XCTestCase {
|
class SocketBasicPacketTest: XCTestCase {
|
||||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import SocketIO
|
@testable import SocketIOClientSwift
|
||||||
|
|
||||||
class SocketEngineTest: XCTestCase {
|
class SocketEngineTest: XCTestCase {
|
||||||
var client: SocketIOClient!
|
var client: SocketIOClient!
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import SocketIO
|
@testable import SocketIOClientSwift
|
||||||
|
|
||||||
class SocketNamespacePacketTest: XCTestCase {
|
class SocketNamespacePacketTest: XCTestCase {
|
||||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import SocketIO
|
@testable import SocketIOClientSwift
|
||||||
|
|
||||||
class SocketParserTest: XCTestCase {
|
class SocketParserTest: XCTestCase {
|
||||||
let testSocket = SocketIOClient(socketURL: "")
|
let testSocket = SocketIOClient(socketURL: "")
|
||||||
|
|||||||
@ -7,7 +7,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
import XCTest
|
import XCTest
|
||||||
@testable import SocketIO
|
@testable import SocketIOClientSwift
|
||||||
|
|
||||||
class SocketSideEffectTest: XCTestCase {
|
class SocketSideEffectTest: XCTestCase {
|
||||||
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
let data = "test".dataUsingEncoding(NSUTF8StringEncoding)!
|
||||||
|
|||||||
@ -26,10 +26,10 @@ import Foundation
|
|||||||
|
|
||||||
public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable {
|
public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable {
|
||||||
public let socketURL: String
|
public let socketURL: String
|
||||||
|
|
||||||
public private(set) var engine: SocketEngineSpec?
|
public private(set) var engine: SocketEngineSpec?
|
||||||
public private(set) var status = SocketIOClientStatus.NotConnected
|
public private(set) var status = SocketIOClientStatus.NotConnected
|
||||||
|
|
||||||
public var connectParams: [String: AnyObject]?
|
public var connectParams: [String: AnyObject]?
|
||||||
public var forceNew = false
|
public var forceNew = false
|
||||||
public var nsp = "/"
|
public var nsp = "/"
|
||||||
@ -39,35 +39,35 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
public var sid: String? {
|
public var sid: String? {
|
||||||
return engine?.sid
|
return engine?.sid
|
||||||
}
|
}
|
||||||
|
|
||||||
private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL)
|
private let emitQueue = dispatch_queue_create("com.socketio.emitQueue", DISPATCH_QUEUE_SERIAL)
|
||||||
private let logType = "SocketIOClient"
|
private let logType = "SocketIOClient"
|
||||||
private let parseQueue = dispatch_queue_create("com.socketio.parseQueue", DISPATCH_QUEUE_SERIAL)
|
private let parseQueue = dispatch_queue_create("com.socketio.parseQueue", DISPATCH_QUEUE_SERIAL)
|
||||||
|
|
||||||
private var anyHandler: ((SocketAnyEvent) -> Void)?
|
private var anyHandler: ((SocketAnyEvent) -> Void)?
|
||||||
private var currentReconnectAttempt = 0
|
private var currentReconnectAttempt = 0
|
||||||
private var handlers = [SocketEventHandler]()
|
private var handlers = [SocketEventHandler]()
|
||||||
private var reconnectTimer: NSTimer?
|
private var reconnectTimer: NSTimer?
|
||||||
private var ackHandlers = SocketAckManager()
|
private var ackHandlers = SocketAckManager()
|
||||||
|
|
||||||
private(set) var currentAck = -1
|
private(set) var currentAck = -1
|
||||||
private(set) var handleQueue = dispatch_get_main_queue()
|
private(set) var handleQueue = dispatch_get_main_queue()
|
||||||
private(set) var reconnectAttempts = -1
|
private(set) var reconnectAttempts = -1
|
||||||
|
|
||||||
var waitingData = [SocketPacket]()
|
var waitingData = [SocketPacket]()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Type safe way to create a new SocketIOClient. opts can be omitted
|
Type safe way to create a new SocketIOClient. opts can be omitted
|
||||||
*/
|
*/
|
||||||
public init(socketURL: String, options: Set<SocketIOClientOption> = []) {
|
public init(socketURL: String, options: Set<SocketIOClientOption> = []) {
|
||||||
self.options = options
|
self.options = options
|
||||||
|
|
||||||
if socketURL["https://"].matches().count != 0 {
|
if socketURL["https://"].matches().count != 0 {
|
||||||
self.options.insertIgnore(.Secure(true))
|
self.options.insertIgnore(.Secure(true))
|
||||||
}
|
}
|
||||||
|
|
||||||
self.socketURL = socketURL["https?://"] ~= ""
|
self.socketURL = socketURL["https?://"] ~= ""
|
||||||
|
|
||||||
for option in options {
|
for option in options {
|
||||||
switch option {
|
switch option {
|
||||||
case let .ConnectParams(params):
|
case let .ConnectParams(params):
|
||||||
@ -92,12 +92,12 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.options.insertIgnore(.Path("/socket.io"))
|
self.options.insertIgnore(.Path("/socket.io"))
|
||||||
|
|
||||||
super.init()
|
super.init()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity.
|
Not so type safe way to create a SocketIOClient, meant for Objective-C compatiblity.
|
||||||
If using Swift it's recommended to use `init(var socketURL: String, opts: SocketOptionsDictionary? = nil)`
|
If using Swift it's recommended to use `init(var socketURL: String, opts: SocketOptionsDictionary? = nil)`
|
||||||
@ -106,86 +106,85 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
self.init(socketURL: socketURL,
|
self.init(socketURL: socketURL,
|
||||||
options: options?.toSocketOptionsSet() ?? [])
|
options: options?.toSocketOptionsSet() ?? [])
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
deinit {
|
||||||
DefaultSocketLogger.Logger.log("Client is being deinit", type: logType)
|
DefaultSocketLogger.Logger.log("Client is being deinit", type: logType)
|
||||||
engine?.close("Client Deinit")
|
engine?.close("Client Deinit")
|
||||||
}
|
}
|
||||||
|
|
||||||
private func addEngine() -> SocketEngineSpec {
|
private func addEngine() -> SocketEngineSpec {
|
||||||
DefaultSocketLogger.Logger.log("Adding engine", type: logType)
|
DefaultSocketLogger.Logger.log("Adding engine", type: logType)
|
||||||
|
|
||||||
engine = SocketEngine(client: self, url: socketURL, options: options)
|
engine = SocketEngine(client: self, url: socketURL, options: options)
|
||||||
|
|
||||||
return engine!
|
return engine!
|
||||||
}
|
}
|
||||||
|
|
||||||
private func clearReconnectTimer() {
|
private func clearReconnectTimer() {
|
||||||
reconnectTimer?.invalidate()
|
reconnectTimer?.invalidate()
|
||||||
reconnectTimer = nil
|
reconnectTimer = nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@available(*, deprecated=6.0)
|
@available(*, deprecated=6.0)
|
||||||
public func close() {
|
public func close() {
|
||||||
disconnect()
|
disconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Connect to the server.
|
Connect to the server.
|
||||||
*/
|
*/
|
||||||
public func connect() {
|
public func connect() {
|
||||||
connect(timeoutAfter: 0, withTimeoutHandler: nil)
|
connect(timeoutAfter: 0, withTimeoutHandler: nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Connect to the server. If we aren't connected after timeoutAfter, call handler
|
Connect to the server. If we aren't connected after timeoutAfter, call handler
|
||||||
*/
|
*/
|
||||||
public func connect(timeoutAfter timeoutAfter: Int,
|
public func connect(timeoutAfter timeoutAfter: Int, withTimeoutHandler handler: (() -> Void)?) {
|
||||||
withTimeoutHandler handler: (() -> Void)?) {
|
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
|
||||||
assert(timeoutAfter >= 0, "Invalid timeout: \(timeoutAfter)")
|
|
||||||
|
guard status != .Connected else {
|
||||||
guard status != .Connected else {
|
DefaultSocketLogger.Logger.log("Tried connecting on an already connected socket",
|
||||||
DefaultSocketLogger.Logger.log("Tried connecting on an already connected socket",
|
type: logType)
|
||||||
type: logType)
|
return
|
||||||
return
|
}
|
||||||
}
|
|
||||||
|
status = .Connecting
|
||||||
status = .Connecting
|
|
||||||
|
if engine == nil || forceNew {
|
||||||
if engine == nil || forceNew {
|
addEngine().open(connectParams)
|
||||||
addEngine().open(connectParams)
|
} else {
|
||||||
} else {
|
engine?.open(connectParams)
|
||||||
engine?.open(connectParams)
|
}
|
||||||
}
|
|
||||||
|
guard timeoutAfter != 0 else { return }
|
||||||
guard timeoutAfter != 0 else { return }
|
|
||||||
|
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
|
||||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeoutAfter) * Int64(NSEC_PER_SEC))
|
|
||||||
|
dispatch_after(time, handleQueue) {[weak self] in
|
||||||
dispatch_after(time, handleQueue) {[weak self] in
|
if let this = self where this.status != .Connected {
|
||||||
if let this = self where this.status != .Connected {
|
this.status = .Closed
|
||||||
this.status = .Closed
|
this.engine?.close("Connect timeout")
|
||||||
this.engine?.close("Connect timeout")
|
|
||||||
|
handler?()
|
||||||
handler?()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func createOnAck(items: [AnyObject]) -> OnAckCallback {
|
private func createOnAck(items: [AnyObject]) -> OnAckCallback {
|
||||||
currentAck += 1
|
currentAck += 1
|
||||||
|
|
||||||
return {[weak self, ack = currentAck] timeout, callback in
|
return {[weak self, ack = currentAck] timeout, callback in
|
||||||
if let this = self {
|
if let this = self {
|
||||||
this.ackHandlers.addAck(ack, callback: callback)
|
this.ackHandlers.addAck(ack, callback: callback)
|
||||||
|
|
||||||
dispatch_async(this.emitQueue) {
|
dispatch_async(this.emitQueue) {
|
||||||
this._emit(items, ack: ack)
|
this._emit(items, ack: ack)
|
||||||
}
|
}
|
||||||
|
|
||||||
if timeout != 0 {
|
if timeout != 0 {
|
||||||
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(timeout * NSEC_PER_SEC))
|
||||||
|
|
||||||
dispatch_after(time, this.handleQueue) {
|
dispatch_after(time, this.handleQueue) {
|
||||||
this.ackHandlers.timeoutAck(ack)
|
this.ackHandlers.timeoutAck(ack)
|
||||||
}
|
}
|
||||||
@ -193,51 +192,51 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func didConnect() {
|
func didConnect() {
|
||||||
DefaultSocketLogger.Logger.log("Socket connected", type: logType)
|
DefaultSocketLogger.Logger.log("Socket connected", type: logType)
|
||||||
status = .Connected
|
status = .Connected
|
||||||
currentReconnectAttempt = 0
|
currentReconnectAttempt = 0
|
||||||
clearReconnectTimer()
|
clearReconnectTimer()
|
||||||
|
|
||||||
// Don't handle as internal because something crazy could happen where
|
// Don't handle as internal because something crazy could happen where
|
||||||
// we disconnect before it's handled
|
// we disconnect before it's handled
|
||||||
handleEvent("connect", data: [], isInternalMessage: false)
|
handleEvent("connect", data: [], isInternalMessage: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
func didDisconnect(reason: String) {
|
func didDisconnect(reason: String) {
|
||||||
guard status != .Closed else {
|
guard status != .Closed else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)
|
DefaultSocketLogger.Logger.log("Disconnected: %@", type: logType, args: reason)
|
||||||
|
|
||||||
status = .Closed
|
status = .Closed
|
||||||
reconnects = false
|
reconnects = false
|
||||||
|
|
||||||
// Make sure the engine is actually dead.
|
// Make sure the engine is actually dead.
|
||||||
engine?.close("Client closed")
|
engine?.close("Client closed")
|
||||||
handleEvent("disconnect", data: [reason], isInternalMessage: true)
|
handleEvent("disconnect", data: [reason], isInternalMessage: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Closes the socket. Only reopen the same socket if you know what you're doing.
|
Closes the socket. Only reopen the same socket if you know what you're doing.
|
||||||
Will turn off automatic reconnects.
|
Will turn off automatic reconnects.
|
||||||
*/
|
*/
|
||||||
public func disconnect() {
|
public func disconnect() {
|
||||||
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
|
DefaultSocketLogger.Logger.log("Closing socket", type: logType)
|
||||||
|
|
||||||
reconnects = false
|
reconnects = false
|
||||||
didDisconnect("Closed")
|
didDisconnect("Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Send a message to the server
|
Send a message to the server
|
||||||
*/
|
*/
|
||||||
public func emit(event: String, _ items: AnyObject...) {
|
public func emit(event: String, _ items: AnyObject...) {
|
||||||
emit(event, withItems: items)
|
emit(event, withItems: items)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Same as emit, but meant for Objective-C
|
Same as emit, but meant for Objective-C
|
||||||
*/
|
*/
|
||||||
@ -246,12 +245,12 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
handleEvent("error", data: ["Tried emitting \(event) when not connected"], isInternalMessage: true)
|
handleEvent("error", data: ["Tried emitting \(event) when not connected"], isInternalMessage: true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatch_async(emitQueue) {
|
dispatch_async(emitQueue) {
|
||||||
self._emit([event] + items)
|
self._emit([event] + items)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Sends a message to the server, requesting an ack. Use the onAck method of SocketAckHandler to add
|
Sends a message to the server, requesting an ack. Use the onAck method of SocketAckHandler to add
|
||||||
an ack.
|
an ack.
|
||||||
@ -259,45 +258,45 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
public func emitWithAck(event: String, _ items: AnyObject...) -> OnAckCallback {
|
public func emitWithAck(event: String, _ items: AnyObject...) -> OnAckCallback {
|
||||||
return emitWithAck(event, withItems: items)
|
return emitWithAck(event, withItems: items)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Same as emitWithAck, but for Objective-C
|
Same as emitWithAck, but for Objective-C
|
||||||
*/
|
*/
|
||||||
public func emitWithAck(event: String, withItems items: [AnyObject]) -> OnAckCallback {
|
public func emitWithAck(event: String, withItems items: [AnyObject]) -> OnAckCallback {
|
||||||
return createOnAck([event] + items)
|
return createOnAck([event] + items)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func _emit(data: [AnyObject], ack: Int? = nil) {
|
private func _emit(data: [AnyObject], ack: Int? = nil) {
|
||||||
guard status == .Connected else {
|
guard status == .Connected else {
|
||||||
handleEvent("error", data: ["Tried emitting when not connected"], isInternalMessage: true)
|
handleEvent("error", data: ["Tried emitting when not connected"], isInternalMessage: true)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
let packet = SocketPacket.packetFromEmit(data, id: ack ?? -1, nsp: nsp, ack: false)
|
let packet = SocketPacket.packetFromEmit(data, id: ack ?? -1, nsp: nsp, ack: false)
|
||||||
let str = packet.packetString
|
let str = packet.packetString
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Emitting: %@", type: logType, args: str)
|
DefaultSocketLogger.Logger.log("Emitting: %@", type: logType, args: str)
|
||||||
|
|
||||||
engine?.send(str, withData: packet.binary)
|
engine?.send(str, withData: packet.binary)
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the server wants to know that the client received data
|
// If the server wants to know that the client received data
|
||||||
func emitAck(ack: Int, withItems items: [AnyObject]) {
|
func emitAck(ack: Int, withItems items: [AnyObject]) {
|
||||||
dispatch_async(emitQueue) {
|
dispatch_async(emitQueue) {
|
||||||
if self.status == .Connected {
|
if self.status == .Connected {
|
||||||
let packet = SocketPacket.packetFromEmit(items, id: ack ?? -1, nsp: self.nsp, ack: true)
|
let packet = SocketPacket.packetFromEmit(items, id: ack ?? -1, nsp: self.nsp, ack: true)
|
||||||
let str = packet.packetString
|
let str = packet.packetString
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Emitting Ack: %@", type: self.logType, args: str)
|
DefaultSocketLogger.Logger.log("Emitting Ack: %@", type: self.logType, args: str)
|
||||||
|
|
||||||
self.engine?.send(str, withData: packet.binary)
|
self.engine?.send(str, withData: packet.binary)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func engineDidClose(reason: String) {
|
public func engineDidClose(reason: String) {
|
||||||
waitingData.removeAll()
|
waitingData.removeAll()
|
||||||
|
|
||||||
if status == .Closed || !reconnects {
|
if status == .Closed || !reconnects {
|
||||||
didDisconnect(reason)
|
didDisconnect(reason)
|
||||||
} else if status != .Reconnecting {
|
} else if status != .Reconnecting {
|
||||||
@ -306,23 +305,23 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
tryReconnect()
|
tryReconnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// error
|
/// error
|
||||||
public func engineDidError(reason: String) {
|
public func engineDidError(reason: String) {
|
||||||
DefaultSocketLogger.Logger.error("%@", type: logType, args: reason)
|
DefaultSocketLogger.Logger.error("%@", type: logType, args: reason)
|
||||||
|
|
||||||
handleEvent("error", data: [reason], isInternalMessage: true)
|
handleEvent("error", data: [reason], isInternalMessage: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called when the socket gets an ack for something it sent
|
// Called when the socket gets an ack for something it sent
|
||||||
func handleAck(ack: Int, data: [AnyObject]) {
|
func handleAck(ack: Int, data: [AnyObject]) {
|
||||||
guard status == .Connected else {return}
|
guard status == .Connected else {return}
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "")
|
DefaultSocketLogger.Logger.log("Handling ack: %@ with data: %@", type: logType, args: ack, data ?? "")
|
||||||
|
|
||||||
ackHandlers.executeAck(ack, items: data)
|
ackHandlers.executeAck(ack, items: data)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Causes an event to be handled. Only use if you know what you're doing.
|
Causes an event to be handled. Only use if you know what you're doing.
|
||||||
*/
|
*/
|
||||||
@ -330,18 +329,18 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
guard status == .Connected || isInternalMessage else {
|
guard status == .Connected || isInternalMessage else {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Handling event: %@ with data: %@", type: logType, args: event, data ?? "")
|
DefaultSocketLogger.Logger.log("Handling event: %@ with data: %@", type: logType, args: event, data ?? "")
|
||||||
|
|
||||||
dispatch_async(handleQueue) {
|
dispatch_async(handleQueue) {
|
||||||
self.anyHandler?(SocketAnyEvent(event: event, items: data))
|
self.anyHandler?(SocketAnyEvent(event: event, items: data))
|
||||||
|
|
||||||
for handler in self.handlers where handler.event == event {
|
for handler in self.handlers where handler.event == event {
|
||||||
handler.executeCallback(data, withAck: ack, withSocket: self)
|
handler.executeCallback(data, withAck: ack, withSocket: self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Leaves nsp and goes back to /
|
Leaves nsp and goes back to /
|
||||||
*/
|
*/
|
||||||
@ -351,104 +350,105 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
nsp = "/"
|
nsp = "/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Joins namespace
|
Joins namespace
|
||||||
*/
|
*/
|
||||||
public func joinNamespace(namespace: String) {
|
public func joinNamespace(namespace: String) {
|
||||||
nsp = namespace
|
nsp = namespace
|
||||||
|
|
||||||
if nsp != "/" {
|
if nsp != "/" {
|
||||||
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
|
DefaultSocketLogger.Logger.log("Joining namespace", type: logType)
|
||||||
engine?.send("0\(nsp)", withData: [])
|
engine?.send("0\(nsp)", withData: [])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes handler(s)
|
Removes handler(s)
|
||||||
*/
|
*/
|
||||||
public func off(event: String) {
|
public func off(event: String) {
|
||||||
DefaultSocketLogger.Logger.log("Removing handler for event: %@", type: logType, args: event)
|
DefaultSocketLogger.Logger.log("Removing handler for event: %@", type: logType, args: event)
|
||||||
|
|
||||||
handlers = handlers.filter { $0.event != event }
|
handlers = handlers.filter { $0.event != event }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes a handler with the specified UUID gotten from an `on` or `once`
|
Removes a handler with the specified UUID gotten from an `on` or `once`
|
||||||
*/
|
*/
|
||||||
public func off(id id: NSUUID) {
|
public func off(id id: NSUUID) {
|
||||||
DefaultSocketLogger.Logger.log("Removing handler with id: %@", type: logType, args: id)
|
DefaultSocketLogger.Logger.log("Removing handler with id: %@", type: logType, args: id)
|
||||||
|
|
||||||
handlers = handlers.filter { $0.id != id }
|
handlers = handlers.filter { $0.id != id }
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds a handler for an event.
|
Adds a handler for an event.
|
||||||
Returns: A unique id for the handler
|
Returns: A unique id for the handler
|
||||||
*/
|
*/
|
||||||
public func on(event: String, callback: NormalCallback) -> NSUUID {
|
public func on(event: String, callback: NormalCallback) -> NSUUID {
|
||||||
DefaultSocketLogger.Logger.log("Adding handler for event: %@", type: logType, args: event)
|
DefaultSocketLogger.Logger.log("Adding handler for event: %@", type: logType, args: event)
|
||||||
|
|
||||||
let handler = SocketEventHandler(event: event, id: NSUUID(), callback: callback)
|
let handler = SocketEventHandler(event: event, id: NSUUID(), callback: callback)
|
||||||
handlers.append(handler)
|
handlers.append(handler)
|
||||||
|
|
||||||
return handler.id
|
return handler.id
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds a single-use handler for an event.
|
Adds a single-use handler for an event.
|
||||||
Returns: A unique id for the handler
|
Returns: A unique id for the handler
|
||||||
*/
|
*/
|
||||||
public func once(event: String, callback: NormalCallback) -> NSUUID {
|
public func once(event: String, callback: NormalCallback) -> NSUUID {
|
||||||
DefaultSocketLogger.Logger.log("Adding once handler for event: %@", type: logType, args: event)
|
DefaultSocketLogger.Logger.log("Adding once handler for event: %@", type: logType, args: event)
|
||||||
|
|
||||||
let id = NSUUID()
|
let id = NSUUID()
|
||||||
|
|
||||||
let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in
|
let handler = SocketEventHandler(event: event, id: id) {[weak self] data, ack in
|
||||||
guard let this = self else {return}
|
guard let this = self else {return}
|
||||||
this.off(id: id)
|
this.off(id: id)
|
||||||
callback(data, ack)
|
callback(data, ack)
|
||||||
}
|
}
|
||||||
|
|
||||||
handlers.append(handler)
|
handlers.append(handler)
|
||||||
|
|
||||||
return handler.id
|
return handler.id
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Adds a handler that will be called on every event.
|
Adds a handler that will be called on every event.
|
||||||
*/
|
*/
|
||||||
public func onAny(handler: (SocketAnyEvent) -> Void) {
|
public func onAny(handler: (SocketAnyEvent) -> Void) {
|
||||||
anyHandler = handler
|
anyHandler = handler
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Same as connect
|
Same as connect
|
||||||
*/
|
*/
|
||||||
public func open() {
|
public func open() {
|
||||||
connect()
|
connect()
|
||||||
}
|
}
|
||||||
|
|
||||||
public func parseEngineMessage(msg: String) {
|
public func parseEngineMessage(msg: String) {
|
||||||
DefaultSocketLogger.Logger.log("Should parse message", type: "SocketIOClient")
|
DefaultSocketLogger.Logger.log("Should parse message: %@", type: "SocketIOClient", args: msg)
|
||||||
|
|
||||||
dispatch_async(parseQueue) {
|
dispatch_async(parseQueue) {
|
||||||
self.parseSocketMessage(msg)
|
self.parseSocketMessage(msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func parseEngineBinaryData(data: NSData) {
|
public func parseEngineBinaryData(data: NSData) {
|
||||||
dispatch_async(parseQueue) {
|
dispatch_async(parseQueue) {
|
||||||
self.parseBinaryData(data)
|
self.parseBinaryData(data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Tries to reconnect to the server.
|
Tries to reconnect to the server.
|
||||||
*/
|
*/
|
||||||
public func reconnect() {
|
public func reconnect() {
|
||||||
tryReconnect()
|
tryReconnect()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Removes all handlers.
|
Removes all handlers.
|
||||||
Can be used after disconnecting to break any potential remaining retain cycles.
|
Can be used after disconnecting to break any potential remaining retain cycles.
|
||||||
@ -456,38 +456,38 @@ public final class SocketIOClient: NSObject, SocketEngineClient, SocketParsable
|
|||||||
public func removeAllHandlers() {
|
public func removeAllHandlers() {
|
||||||
handlers.removeAll(keepCapacity: false)
|
handlers.removeAll(keepCapacity: false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func tryReconnect() {
|
private func tryReconnect() {
|
||||||
if reconnectTimer == nil {
|
if reconnectTimer == nil {
|
||||||
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
DefaultSocketLogger.Logger.log("Starting reconnect", type: logType)
|
||||||
|
|
||||||
status = .Reconnecting
|
status = .Reconnecting
|
||||||
|
|
||||||
dispatch_async(dispatch_get_main_queue()) {
|
dispatch_async(dispatch_get_main_queue()) {
|
||||||
self.reconnectTimer = NSTimer.scheduledTimerWithTimeInterval(Double(self.reconnectWait),
|
self.reconnectTimer = NSTimer.scheduledTimerWithTimeInterval(Double(self.reconnectWait),
|
||||||
target: self, selector: "_tryReconnect", userInfo: nil, repeats: true)
|
target: self, selector: "_tryReconnect", userInfo: nil, repeats: true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@objc private func _tryReconnect() {
|
@objc private func _tryReconnect() {
|
||||||
if status == .Connected {
|
if status == .Connected {
|
||||||
clearReconnectTimer()
|
clearReconnectTimer()
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects {
|
if reconnectAttempts != -1 && currentReconnectAttempt + 1 > reconnectAttempts || !reconnects {
|
||||||
clearReconnectTimer()
|
clearReconnectTimer()
|
||||||
didDisconnect("Reconnect Failed")
|
didDisconnect("Reconnect Failed")
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultSocketLogger.Logger.log("Trying to reconnect", type: logType)
|
DefaultSocketLogger.Logger.log("Trying to reconnect", type: logType)
|
||||||
handleEvent("reconnectAttempt", data: [reconnectAttempts - currentReconnectAttempt],
|
handleEvent("reconnectAttempt", data: [reconnectAttempts - currentReconnectAttempt],
|
||||||
isInternalMessage: true)
|
isInternalMessage: true)
|
||||||
|
|
||||||
currentReconnectAttempt += 1
|
currentReconnectAttempt += 1
|
||||||
connect()
|
connect()
|
||||||
}
|
}
|
||||||
@ -498,15 +498,15 @@ extension SocketIOClient {
|
|||||||
var testHandlers: [SocketEventHandler] {
|
var testHandlers: [SocketEventHandler] {
|
||||||
return handlers
|
return handlers
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTestable() {
|
func setTestable() {
|
||||||
status = .Connected
|
status = .Connected
|
||||||
}
|
}
|
||||||
|
|
||||||
func setTestEngine(engine: SocketEngineSpec?) {
|
func setTestEngine(engine: SocketEngineSpec?) {
|
||||||
self.engine = engine
|
self.engine = engine
|
||||||
}
|
}
|
||||||
|
|
||||||
func emitTest(event: String, _ data: AnyObject...) {
|
func emitTest(event: String, _ data: AnyObject...) {
|
||||||
self._emit([event] + data)
|
self._emit([event] + data)
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user