Skip to content

Commit

Permalink
Update and merge conflicts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Romixery committed May 17, 2024
1 parent 7cdb544 commit 35c78c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func onError(swiftStomp : SwiftStomp, briefDescription : String, fullDescription
```

### Upstreams
In the case that you are more comfort to use `Combine` publishers, instead of delegate, SwiftStomp can report all `event`s, `message`s and `receiptId`s through upstreams. This functionality shines, especially, when you want to use SwiftStomp in the SwiftUI projects.
In the case that you are more comfort to use `Combine` publishers, instead of delegate, SwiftStomp can report all `event`s, `message`s and `receiptId`s through upstreams. This functionality shines, especially, when you want to use SwiftStomp in the SwiftUI projects. Please check the example project, to see how we can use upstreams, in SwiftUI projects.

```swift
// ** Subscribe to events: [Connect/Disconnect/Errors]
Expand Down
31 changes: 5 additions & 26 deletions SwiftStomp/Classes/SwiftStomp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -574,49 +574,28 @@ extension SwiftStomp {
switch result {
case .failure(let error):
self?.stompLog(type: .socketError, message: "Socket listen: Error: \(error)")

self?.callbacksThread.async { [weak self] in
guard let self else { return }
self.delegate?.onError(swiftStomp: self, briefDescription: "Stomp Error", fullDescription: error.localizedDescription, receiptId: nil, type: .fromStomp)
}

case .success(let message):
switch message {
case .string(let text):
self?.stompLog(type: .info, message: "Socket: Received text")
self?.processReceivedSocketText(text: text)

case .data(let data):
self?.stompLog(type: .info, message: "Socket: Received data: \(data.count)")

default:
break
}

// Keep listening
self?.listen()
}
case .error(let error):
self.status = .socketDisconnected

stompLog(type: .socketError, message: "Socket: Error: \(error.debugDescription)")
self.delegate?.onError(swiftStomp: self, briefDescription: "Socket Error", fullDescription: error?.localizedDescription, receiptId: nil, type: .fromSocket)

if self.autoReconnect{
self.scheduleConnector()
}
case .peerClosed:
self.status = .socketDisconnected

stompLog(type: .info, message: "Socket: Peer closed")

self.delegate?.onSocketEvent(eventName: "peerClosed", description: "Socket Closed by Peer")

if self.autoReconnect{
self.scheduleConnector()
}
@unknown default:
stompLog(type: .info, message: "Socket: Unexpected event kind: \(String(describing: event))")
}
}
}
Expand Down

0 comments on commit 35c78c2

Please sign in to comment.