Skip to content
This repository was archived by the owner on Jun 13, 2023. It is now read-only.
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
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ subscription.handle(Event.Created) { query, object in
}
```

By default, it will print the logs from WebSocket / WebSocketDelegate. You can turn it off:
```swift
Client.shared.shouldPrintWebSocketLog = false
```

Handling errors is and other events is similar, take a look at the `Subscription` class for more information.

## Advanced Usage
Expand All @@ -65,7 +70,7 @@ We want to make contributing to this project as easy and transparent as possible

-----

As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.
As of April 5, 2017, Parse, LLC has transferred this code to the parse-community organization, and will no longer be contributing to or distributing this code.

[releases]: https://github.com/parse-community/ParseLiveQuery-iOS-OSX/releases
[contributing]: https://github.com/parse-community/ParseLiveQuery-iOS-OSX/blob/master/CONTRIBUTING.md
Expand All @@ -87,4 +92,3 @@ As of April 5, 2017, Parse, LLC has transferred this code to the parse-community

[carthage-svg]:https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat
[carthage-link]:https://github.com/Carthage/Carthage

1 change: 1 addition & 0 deletions Sources/ParseLiveQuery/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ open class Client: NSObject {
let clientKey: String?

var socket: WebSocket?
public var shouldPrintWebSocketLog = true
public var userDisconnected = false

// This allows us to easily plug in another request ID generation scheme, or more easily change the request id type
Expand Down
10 changes: 5 additions & 5 deletions Sources/ParseLiveQuery/Internal/ClientPrivate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ func == (first: Client.RequestId, second: Client.RequestId) -> Bool {
extension Client: WebSocketDelegate {

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

public func websocketDidReceiveMessage(socket: WebSocket, text: String) {
handleOperationAsync(text).continueWith { task in
if let error = task.error {
handleOperationAsync(text).continueWith { [weak self] task in
if let error = task.error, self?.shouldPrintWebSocketLog == true {
print("Error: \(error)")
}
}
Expand All @@ -134,7 +134,7 @@ extension Client: WebSocketDelegate {
}

public func websocketDidDisconnect(socket: WebSocket, error: NSError?) {
print("error: \(error)")
if shouldPrintWebSocketLog { print("error: \(String(describing: error))") }

// TODO: Better retry logic, unless `disconnect()` was explicitly called
if !userDisconnected {
Expand All @@ -143,7 +143,7 @@ extension Client: WebSocketDelegate {
}

public func webSocket(_ webSocket: WebSocket, didCloseWithCode code: Int, reason: String?, wasClean: Bool) {
print("code: \(code) reason: \(reason)")
if shouldPrintWebSocketLog { print("code: \(code) reason: \(String(describing: reason))") }

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