Scarlet icon indicating copy to clipboard operation
Scarlet copied to clipboard

Not subscribing to events

Open rok5ek opened this issue 7 years ago • 0 comments

Hy im using the 0.1.7 branch from Jitpack.

Currently I have this code and the logs don't display the "socket send event" message.

However I get the message from OkHttp OkHttp: <-- 101 Switching Protocols https://ws.bitstamp.net/ (147ms)

Which means the handshake was successful, but the connection isn't somehow opened? I also tried commenting out the filter operator without success.

My subscribe code looks like this:

val event = SocketEventFactory.createEvent() val repo = appRepository.observeWebSocketEvent() .filter { it is WebSocket.Event.OnConnectionOpened<*> } .subscribe({ Timber.i("[app] socket send event:%s", event) appRepository.sendEvent(event) }, { e -> Timber.e(e, "[app] socket error") })

I think theres a lifecycle issue, since when I put the app into background and then go back in, the observer receives events. I mean to say that even though I subscribe to the socket in onResume() method, it doesn't get initiated and when I put the app in background and then resume again the sockets start working.

rok5ek avatar Mar 20 '19 14:03 rok5ek