Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.

Update sockets #236

Merged
merged 20 commits into from
Nov 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,17 +79,14 @@ jobs:
- run: |
xcodebuild clean -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo | xcpretty -c;
xcodebuild build -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo -configuration Debug | xcpretty -c;
- run: |
xcodebuild clean -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo-ObjC | xcpretty -c;
xcodebuild build -workspace ParseLiveQuery.xcworkspace -scheme LiveQueryDemo-ObjC -configuration Debug | xcpretty -c;
carthage:
<<: *defaults
steps:
- checkout
- restore_cache: *cache-pull
- run: *prepare
- save_cache: *cache-push
- run: carthage build --no-skip-current --platform macos,ios
- run: carthage build --no-skip-current --platform macos,ios,tvos,watchos

workflows:
version: 2
Expand Down
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
deploy:
provider: script
skip_cleanup: true
script: travis_wait bundle exec pod trunk push ParseLiveQuery.podspec --allow-warnings
script: bundle exec pod trunk push ParseLiveQuery.podspec --allow-warnings
on:
tags: true
all_branches: true
Expand Down
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@

### Master

[Full Changelog](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/compare/2.7.3...master)
[Full Changelog](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/compare/2.8.0...master)

### 2.8.0

[Full Changelog](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/compare/2.7.3...2.8.0)

- Bump Starscream dependency to >= 4.0.4 ([#236](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6).
- Bump Parse SDK to v.1.19.1 ([#236](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6).
- Minimum support due to Xcode 12 and dependencies (iOS 9) ([#236](https://github.com/parse-community/ParseLiveQuery-iOS-OSX/pull/236)), thanks to [Corey Baker](https://github.com/cbaker6).

### 2.7.3

Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
github "BoltsFramework/Bolts-Swift" >= 1.5.0
github "ParsePlatform/Parse-SDK-iOS-OSX" >= 1.19.1
github "daltoniam/Starscream" == 3.1.1
github "daltoniam/Starscream" >= 4.0.4
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
github "BoltsFramework/Bolts-ObjC" "1.9.1"
github "BoltsFramework/Bolts-Swift" "1.5.0"
github "ParsePlatform/Parse-SDK-iOS-OSX" "1.19.1"
github "daltoniam/Starscream" "3.1.1"
github "daltoniam/Starscream" "4.0.4"
github "facebook/facebook-objc-sdk" "v6.5.2"
2 changes: 1 addition & 1 deletion Carthage/Checkouts/Starscream
Submodule Starscream updated 46 files
+1 −1 .travis.yml
+38 −0 CHANGELOG.md
+64 −59 Gemfile.lock
+8 −5 Package.swift
+67 −197 README.md
+29 −0 Sources/Compression/Compression.swift
+87 −17 Sources/Compression/WSCompression.swift
+53 −0 Sources/DataBytes/Data+Extensions.swift
+22 −0 Sources/Engine/Engine.swift
+96 −0 Sources/Engine/NativeEngine.swift
+234 −0 Sources/Engine/WSEngine.swift
+123 −0 Sources/Framer/FoundationHTTPHandler.swift
+99 −0 Sources/Framer/FoundationHTTPServerHandler.swift
+107 −0 Sources/Framer/FrameCollector.swift
+365 −0 Sources/Framer/Framer.swift
+148 −0 Sources/Framer/HTTPHandler.swift
+143 −0 Sources/Framer/StringHTTPHandler.swift
+1 −1 Sources/Info.plist
+101 −0 Sources/Security/FoundationSecurity.swift
+45 −0 Sources/Security/Security.swift
+56 −0 Sources/Server/Server.swift
+196 −0 Sources/Server/WebSocketServer.swift
+0 −92 Sources/Starscream/SSLClientCertificate.swift
+0 −266 Sources/Starscream/SSLSecurity.swift
+82 −1,260 Sources/Starscream/WebSocket.swift
+218 −0 Sources/Transport/FoundationTransport.swift
+159 −0 Sources/Transport/TCPTransport.swift
+55 −0 Sources/Transport/Transport.swift
+1 −1 Starscream.podspec
+179 −20 Starscream.xcodeproj/project.pbxproj
+185 −0 Tests/FuzzingTests.swift
+130 −0 Tests/MockServer.swift
+65 −0 Tests/MockTransport.swift
+1 −1 build.sh
+41 −193 examples/AutobahnTest/Autobahn.xcodeproj/project.pbxproj
+1 −1 examples/AutobahnTest/Autobahn/AppDelegate.swift
+30 −0 examples/AutobahnTest/Autobahn/Images.xcassets/AppIcon.appiconset/Contents.json
+101 −83 examples/AutobahnTest/Autobahn/ViewController.swift
+0 −36 examples/AutobahnTest/AutobahnTests/AutobahnTests.swift
+0 −24 examples/AutobahnTest/AutobahnTests/Info.plist
+20 −72 examples/SimpleTest/SimpleTest.xcodeproj/project.pbxproj
+ ...eTest/SimpleTest.xcodeproj/project.xcworkspace/xcuserdata/dalton.xcuserdatad/UserInterfaceState.xcuserstate
+16 −2 examples/SimpleTest/SimpleTest/AppDelegate.swift
+5 −0 examples/SimpleTest/SimpleTest/Info.plist
+64 −19 examples/SimpleTest/SimpleTest/ViewController.swift
+1 −1 fastlane/README.md
6 changes: 3 additions & 3 deletions ParseLiveQuery.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ParseLiveQuery'
s.version = '2.7.3'
s.version = '2.8.0'
s.license = { :type => 'BSD' }
s.summary = 'Allows for subscriptions to queries in conjunction with parse-server.'
s.homepage = 'http://parseplatform.org'
Expand All @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.swift_version = '5.0'
s.cocoapods_version = '>= 1.4'

s.ios.deployment_target = '8.0'
s.ios.deployment_target = '9.0'
s.tvos.deployment_target = '10.0'
s.watchos.deployment_target = '2.0'
s.osx.deployment_target = '10.10'
Expand All @@ -25,6 +25,6 @@ Pod::Spec.new do |s|

s.dependency 'Parse', '~> 1.19.0'
s.dependency 'Bolts-Swift', '~> 1.5.0'
s.dependency 'Starscream', '3.1.0'
s.dependency 'Starscream', '~> 4.0.4'

end
2 changes: 1 addition & 1 deletion Sources/ParseLiveQuery-tvOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
2 changes: 1 addition & 1 deletion Sources/ParseLiveQuery-watchOS/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>$(PRODUCT_BUNDLE_PACKAGE_TYPE)</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
</dict>
Expand Down
20 changes: 12 additions & 8 deletions Sources/ParseLiveQuery.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,7 @@
INFOPLIST_FILE = "ParseLiveQuery-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 2.8.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.watchos.ParseLiveQuery-watchOS";
Expand Down Expand Up @@ -1111,6 +1112,7 @@
INFOPLIST_FILE = "ParseLiveQuery-watchOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 2.8.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.watchos.ParseLiveQuery-watchOS";
Expand Down Expand Up @@ -1161,6 +1163,7 @@
INFOPLIST_FILE = "ParseLiveQuery-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 2.8.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.tvos.ParseLiveQuery-tvOS";
Expand Down Expand Up @@ -1207,6 +1210,7 @@
INFOPLIST_FILE = "ParseLiveQuery-tvOS/Info.plist";
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
MARKETING_VERSION = 2.8.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = "com.parse.livequery.tvos.ParseLiveQuery-tvOS";
Expand Down Expand Up @@ -1252,7 +1256,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACOSX_DEPLOYMENT_TARGET = 10.12;
ONLY_ACTIVE_ARCH = YES;
SWIFT_OBJC_BRIDGING_HEADER = "";
Expand Down Expand Up @@ -1289,7 +1293,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
MACOSX_DEPLOYMENT_TARGET = 10.12;
SWIFT_OBJC_BRIDGING_HEADER = "";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -1314,7 +1318,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 2.7.3;
MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.osx;
PRODUCT_NAME = ParseLiveQuery;
SDKROOT = macosx;
Expand All @@ -1341,7 +1345,7 @@
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.10;
MARKETING_VERSION = 2.7.3;
MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.osx;
PRODUCT_NAME = ParseLiveQuery;
SDKROOT = macosx;
Expand All @@ -1364,10 +1368,10 @@
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = ParseLiveQuery/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 2.7.3;
MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.ios;
PRODUCT_NAME = ParseLiveQuery;
SDKROOT = iphoneos;
Expand All @@ -1393,10 +1397,10 @@
FRAMEWORK_VERSION = A;
INFOPLIST_FILE = ParseLiveQuery/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
LIBRARY_SEARCH_PATHS = "$(inherited)";
MARKETING_VERSION = 2.7.3;
MARKETING_VERSION = 2.8.0;
PRODUCT_BUNDLE_IDENTIFIER = com.parse.livequery.ios;
PRODUCT_NAME = ParseLiveQuery;
SDKROOT = iphoneos;
Expand Down
19 changes: 10 additions & 9 deletions Sources/ParseLiveQuery/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,18 @@ extension Client {
requestId: requestIdGenerator(),
handler: handler
)
subscriptions.append(subscriptionRecord)

self.subscriptions.append(subscriptionRecord)

if let socket = socket, socket.isConnected == true {
_ = sendOperationAsync(.subscribe(requestId: subscriptionRecord.requestId, query: query as! PFQuery<PFObject>,
if socket != nil {
_ = self.sendOperationAsync(.subscribe(requestId: subscriptionRecord.requestId, query: query as! PFQuery<PFObject>,
sessionToken: PFUser.current()?.sessionToken))
} else if !self.userDisconnected {
self.reconnect()
self.subscriptions.removeLast()
return self.subscribe(query, handler: handler)
} else {
if !userDisconnected {
reconnect()
} else {
NSLog("ParseLiveQuery: Warning: The client was explicitly disconnected! You must explicitly call .reconnect() in order to process your subscriptions.")
}
NSLog("ParseLiveQuery: Warning: The client was explicitly disconnected! You must explicitly call .reconnect() in order to process your subscriptions.")
}

return handler
Expand Down Expand Up @@ -233,7 +234,7 @@ extension Client {
guard socket == nil || !isConnecting else { return }
socket?.disconnect()
socket = {
let socket = WebSocket(url: host)
let socket = WebSocket(request: .init(url: host))
socket.delegate = self
socket.callbackQueue = queue
socket.connect()
Expand Down
51 changes: 26 additions & 25 deletions Sources/ParseLiveQuery/Internal/ClientPrivate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,32 +115,33 @@ func == (first: Client.RequestId, second: Client.RequestId) -> Bool {
// ---------------

extension Client: WebSocketDelegate {

public func websocketDidReceiveData(socket: WebSocketClient, data: Data) {
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: Received binary data but we don't handle it...") }
}

public func websocketDidReceiveMessage(socket: WebSocketClient, text: String) {
handleOperationAsync(text).continueWith { [weak self] task in
if let error = task.error, self?.shouldPrintWebSocketLog == true {
NSLog("ParseLiveQuery: Error processing message: \(error)")
public func didReceive(event: WebSocketEvent, client: WebSocket) {
switch event {

case .connected(_):
isConnecting = false
let sessionToken = PFUser.current()?.sessionToken ?? ""
_ = self.sendOperationAsync(.connect(applicationId: applicationId, sessionToken: sessionToken, clientKey: clientKey))
case .disconnected(let reason, let code):
isConnecting = false
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: WebSocket did disconnect with error: \(reason) code:\(code)") }

// TODO: Better retry logic, unless `disconnect()` was explicitly called
if !userDisconnected {
reconnect()
}
}
}

public func websocketDidConnect(socket: WebSocketClient) {
isConnecting = false
let sessionToken = PFUser.current()?.sessionToken ?? ""
_ = self.sendOperationAsync(.connect(applicationId: applicationId, sessionToken: sessionToken, clientKey: clientKey))
}

public func websocketDidDisconnect(socket: WebSocketClient, error: Error?) {
isConnecting = false
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: WebSocket did disconnect with error: \(String(describing: error))") }

// TODO: Better retry logic, unless `disconnect()` was explicitly called
if !userDisconnected {
reconnect()
case .text(let text):
handleOperationAsync(text).continueWith { [weak self] task in
if let error = task.error, self?.shouldPrintWebSocketLog == true {
NSLog("ParseLiveQuery: Error processing message: \(error)")
}
}
case .binary(_):
if shouldPrintWebSocketLog { NSLog("ParseLiveQuery: Received binary data but we don't handle it...") }
case .error(let error):
NSLog("ParseLiveQuery: Error processing message: \(String(describing: error))")
default:
break
}
}
}
Expand Down