You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a working WAMP implementation that crashes every 50 times or so. It happens when I leave the screen and the disconnect() method gets called:
class WampConnector: NSObject {
static var authid = ""
let wampEndpoint = "ws://wamp.workspace-beta.nl:9090"
let realm = "workspace"
let swampTransport: WebSocketSwampTransport
let swampSession: SwampSession
init?(withDelegate delegate: SwampSessionDelegate) {
let url = URL(string: wampEndpoint) ?? URL(fileURLWithPath: "")
swampTransport = WebSocketSwampTransport(wsEndpoint: url)
swampSession = SwampSession(realm: realm, transport: swampTransport, authmethods: ["ticket"])
swampSession.delegate = delegate
swampSession.connect()
super.init()
}
func disconnect() {
swampSession.disconnect("Leaving screen")
}
}
The error occurs when force-unwrapping the serializer and/or data.
fileprivate func sendMessage(_ message: SwampMessage){
let marshalledMessage = message.marshal()
let data = self.serializer!.pack(marshalledMessage as [Any])!
self.transport.sendData(data)
}
I notice force unwrapping is the default way to handle optionals in the library, probably to ensure errors get caught early instead of just returning after a guard statement and failing silently. But I think this error occurs because of some kind of race condition that's really hard to reproduce and it might be safer to guard let everything and return when the serializer is gone or no data instance is created.
The text was updated successfully, but these errors were encountered:
I have a working WAMP implementation that crashes every 50 times or so. It happens when I leave the screen and the disconnect() method gets called:
The error occurs when force-unwrapping the serializer and/or data.
I notice force unwrapping is the default way to handle optionals in the library, probably to ensure errors get caught early instead of just returning after a guard statement and failing silently. But I think this error occurs because of some kind of race condition that's really hard to reproduce and it might be safer to guard let everything and return when the serializer is gone or no data instance is created.
The text was updated successfully, but these errors were encountered: