Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Objective-C merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Dec 17, 2015
2 parents a7c4b30 + 2b74174 commit dc59372
Show file tree
Hide file tree
Showing 9 changed files with 439 additions and 44 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SwiftWebSocket passes all 521 of the Autobahn's fuzzing tests, including strict
- Strict UTF-8 processing.
- `binaryType` property to choose between `[UInt8]` or `NSData` messages.
- Zero asserts. All networking, stream, and protocol errors are routed through the `error` event.
- Objective-C compatibility.

## Example

Expand Down
159 changes: 115 additions & 44 deletions Source/WebSocket.swift

Large diffs are not rendered by default.

115 changes: 115 additions & 0 deletions SwiftWebSocket.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
D71948F51B35E5670015C529 /* SwiftWebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = D71948F11B35E5670015C529 /* SwiftWebSocket.h */; settings = {ATTRIBUTES = (Public, ); }; };
D719491A1B35E6640015C529 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D71948FA1B35E59D0015C529 /* libz.dylib */; };
D719491B1B35E7510015C529 /* SwiftWebSocket.h in Headers */ = {isa = PBXBuildFile; fileRef = D71948F11B35E5670015C529 /* SwiftWebSocket.h */; settings = {ATTRIBUTES = (Public, ); }; };
D734D9EC1C232E6A00437555 /* Connection.m in Sources */ = {isa = PBXBuildFile; fileRef = D734D9EB1C232E6A00437555 /* Connection.m */; };
D78C40331C232C3800EB72AA /* Test_ObjectiveC.m in Sources */ = {isa = PBXBuildFile; fileRef = D78C40321C232C3800EB72AA /* Test_ObjectiveC.m */; };
D78C40351C232C3800EB72AA /* SwiftWebSocket.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 03D1E7031B20897100AC49AC /* SwiftWebSocket.framework */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand All @@ -34,6 +37,13 @@
remoteGlobalIDString = 03D1E7021B20897100AC49AC;
remoteInfo = "SwiftWebSocket-iOS";
};
D78C40361C232C3800EB72AA /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = 03D1E6FA1B20897100AC49AC /* Project object */;
proxyType = 1;
remoteGlobalIDString = 03D1E7021B20897100AC49AC;
remoteInfo = "SwiftWebSocket-iOS";
};
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
Expand All @@ -48,6 +58,11 @@
D71948F11B35E5670015C529 /* SwiftWebSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftWebSocket.h; sourceTree = "<group>"; };
D71948FA1B35E59D0015C529 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib/libz.dylib; sourceTree = DEVELOPER_DIR; };
D71949011B35E6130015C529 /* SwiftWebSocket.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SwiftWebSocket.framework; sourceTree = BUILT_PRODUCTS_DIR; };
D734D9EA1C232E6A00437555 /* Connection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Connection.h; sourceTree = "<group>"; };
D734D9EB1C232E6A00437555 /* Connection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Connection.m; sourceTree = "<group>"; };
D78C40301C232C3800EB72AA /* Test-ObjectiveC.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "Test-ObjectiveC.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
D78C40321C232C3800EB72AA /* Test_ObjectiveC.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = Test_ObjectiveC.m; sourceTree = "<group>"; };
D78C40341C232C3800EB72AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -83,6 +98,14 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D78C402D1C232C3800EB72AA /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D78C40351C232C3800EB72AA /* SwiftWebSocket.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
Expand All @@ -93,6 +116,7 @@
03D1E7211B208A5C00AC49AC /* libz.dylib */,
D71948F01B35E5670015C529 /* Source */,
03D70CE71BDAC70100D245C3 /* Test */,
D78C40311C232C3800EB72AA /* Test-ObjectiveC */,
03D1E7041B20897100AC49AC /* Products */,
);
sourceTree = "<group>";
Expand All @@ -104,6 +128,7 @@
D71949011B35E6130015C529 /* SwiftWebSocket.framework */,
03D70CCC1BDAC5EC00D245C3 /* Test-OSX.xctest */,
03D70CDB1BDAC63600D245C3 /* Test-iOS.xctest */,
D78C40301C232C3800EB72AA /* Test-ObjectiveC.xctest */,
);
name = Products;
sourceTree = "<group>";
Expand All @@ -127,6 +152,17 @@
path = Source;
sourceTree = "<group>";
};
D78C40311C232C3800EB72AA /* Test-ObjectiveC */ = {
isa = PBXGroup;
children = (
D78C40341C232C3800EB72AA /* Info.plist */,
D734D9EA1C232E6A00437555 /* Connection.h */,
D734D9EB1C232E6A00437555 /* Connection.m */,
D78C40321C232C3800EB72AA /* Test_ObjectiveC.m */,
);
path = "Test-ObjectiveC";
sourceTree = "<group>";
};
/* End PBXGroup section */

/* Begin PBXHeadersBuildPhase section */
Expand Down Expand Up @@ -221,6 +257,24 @@
productReference = D71949011B35E6130015C529 /* SwiftWebSocket.framework */;
productType = "com.apple.product-type.framework";
};
D78C402F1C232C3800EB72AA /* Test-ObjectiveC */ = {
isa = PBXNativeTarget;
buildConfigurationList = D78C403A1C232C3800EB72AA /* Build configuration list for PBXNativeTarget "Test-ObjectiveC" */;
buildPhases = (
D78C402C1C232C3800EB72AA /* Sources */,
D78C402D1C232C3800EB72AA /* Frameworks */,
D78C402E1C232C3800EB72AA /* Resources */,
);
buildRules = (
);
dependencies = (
D78C40371C232C3800EB72AA /* PBXTargetDependency */,
);
name = "Test-ObjectiveC";
productName = "Test-ObjectiveC";
productReference = D78C40301C232C3800EB72AA /* Test-ObjectiveC.xctest */;
productType = "com.apple.product-type.bundle.unit-test";
};
/* End PBXNativeTarget section */

/* Begin PBXProject section */
Expand All @@ -243,6 +297,9 @@
D71949001B35E6130015C529 = {
CreatedOnToolsVersion = 6.3.2;
};
D78C402F1C232C3800EB72AA = {
CreatedOnToolsVersion = 7.1.1;
};
};
};
buildConfigurationList = 03D1E6FD1B20897100AC49AC /* Build configuration list for PBXProject "SwiftWebSocket" */;
Expand All @@ -261,6 +318,7 @@
D71949001B35E6130015C529 /* SwiftWebSocket-OSX */,
03D70CCB1BDAC5EC00D245C3 /* Test-OSX */,
03D70CDA1BDAC63600D245C3 /* Test-iOS */,
D78C402F1C232C3800EB72AA /* Test-ObjectiveC */,
);
};
/* End PBXProject section */
Expand Down Expand Up @@ -294,6 +352,13 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D78C402E1C232C3800EB72AA /* Resources */ = {
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXResourcesBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down Expand Up @@ -329,6 +394,15 @@
);
runOnlyForDeploymentPostprocessing = 0;
};
D78C402C1C232C3800EB72AA /* Sources */ = {
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D78C40331C232C3800EB72AA /* Test_ObjectiveC.m in Sources */,
D734D9EC1C232E6A00437555 /* Connection.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXSourcesBuildPhase section */

/* Begin PBXTargetDependency section */
Expand All @@ -342,6 +416,11 @@
target = 03D1E7021B20897100AC49AC /* SwiftWebSocket-iOS */;
targetProxy = 03D70CE11BDAC63600D245C3 /* PBXContainerItemProxy */;
};
D78C40371C232C3800EB72AA /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 03D1E7021B20897100AC49AC /* SwiftWebSocket-iOS */;
targetProxy = D78C40361C232C3800EB72AA /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */

/* Begin XCBuildConfiguration section */
Expand Down Expand Up @@ -572,6 +651,31 @@
};
name = Release;
};
D78C40381C232C3800EB72AA /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEBUG_INFORMATION_FORMAT = dwarf;
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = "Test-ObjectiveC/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.oncast.Test-ObjectiveC";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
};
D78C40391C232C3800EB72AA /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
EMBEDDED_CONTENT_CONTAINS_SWIFT = YES;
INFOPLIST_FILE = "Test-ObjectiveC/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 9.1;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.oncast.Test-ObjectiveC";
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
};
/* End XCBuildConfiguration section */

/* Begin XCConfigurationList section */
Expand Down Expand Up @@ -600,6 +704,7 @@
03D70CD51BDAC5EC00D245C3 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
03D70CE31BDAC63600D245C3 /* Build configuration list for PBXNativeTarget "Test-iOS" */ = {
isa = XCConfigurationList;
Expand All @@ -608,6 +713,7 @@
03D70CE51BDAC63600D245C3 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D71949141B35E6160015C529 /* Build configuration list for PBXNativeTarget "SwiftWebSocket-OSX" */ = {
isa = XCConfigurationList;
Expand All @@ -618,6 +724,15 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
D78C403A1C232C3800EB72AA /* Build configuration list for PBXNativeTarget "Test-ObjectiveC" */ = {
isa = XCConfigurationList;
buildConfigurations = (
D78C40381C232C3800EB72AA /* Debug */,
D78C40391C232C3800EB72AA /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
rootObject = 03D1E6FA1B20897100AC49AC /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,26 @@
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "D78C402F1C232C3800EB72AA"
BuildableName = "Test-ObjectiveC.xctest"
BlueprintName = "Test-ObjectiveC"
ReferencedContainer = "container:SwiftWebSocket.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "03D1E7021B20897100AC49AC"
BuildableName = "SwiftWebSocket.framework"
BlueprintName = "SwiftWebSocket-iOS"
ReferencedContainer = "container:SwiftWebSocket.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
Expand Down
15 changes: 15 additions & 0 deletions Test-ObjectiveC/Connection.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// Connection.h
// SwiftWebSocket
//
// Created by Ricardo Pereira on 17/12/15.
// Copyright © 2015 ONcast, LLC. All rights reserved.
//

#import <Foundation/Foundation.h>

@interface Connection : NSObject

- (void)open;

@end
64 changes: 64 additions & 0 deletions Test-ObjectiveC/Connection.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
//
// Connection.m
// SwiftWebSocket
//
// Created by Ricardo Pereira on 17/12/15.
// Copyright © 2015 ONcast, LLC. All rights reserved.
//

#import "Connection.h"
#import <SwiftWebSocket/SwiftWebSocket-Swift.h>

@interface Connection () <WebSocketDelegate>

@end

@implementation Connection {
WebSocket *_webSocket;
}

- (instancetype)init {
if (self = [super init]) {
_webSocket = nil;
}
return self;
}

- (void)open {
_webSocket = [[WebSocket alloc] init:@"ws://localhost:9000"];
_webSocket.delegate = self;
[_webSocket open];
}

- (void)webSocketOpen {
NSLog(@"Open");
[_webSocket sendWithText:@"test"];
[_webSocket sendWithData:[@"test" dataUsingEncoding:NSUTF8StringEncoding]];
[_webSocket close:0 reason:@""];
}

- (void)webSocketClose:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean {
NSLog(@"Close: %@", reason);
}

- (void)webSocketMessageText:(NSString *)text {
NSLog(@"Message: %@", text);
}

- (void)webSocketMessageData:(NSData *)data {
NSLog(@"Message: %@", data);
}

- (void)webSocketPong {
NSLog(@"Pong");
}

- (void)webSocketError:(NSError *)error {
NSLog(@"Error: %@", error);
}

- (void)webSocketEnd:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean error:(NSError *)error {
NSLog(@"End: %@", error);
}

@end
24 changes: 24 additions & 0 deletions Test-ObjectiveC/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
</dict>
</plist>
Loading

0 comments on commit dc59372

Please sign in to comment.