Closed Canato closed 10 months ago
Hi! The reconnection events are emitted by the Manager, which can be accessed with socket.io()
:
socket.io().on(Manager.EVENT_RECONNECT_ATTEMPT, () -> {
// ...
});
Ahhh I see!
I was doing
socket = IO.socket(url, options).connect().apply {
on(Socket.EVENT_CONNECT) {
Log.i("Canatoxxx", "OPEN: ${Socket.EVENT_CONNECT}")
trySend(CustomEvent.Connect)
}
on(Manager.EVENT_RECONNECT_FAILED) {
Log.i("Canatoxxx", "OPEN: ${Manager.EVENT_RECONNECT_FAILED}")
trySend(CustomEvent.ReconnectionFailed)
}
(...)
}
And should be
socket = IO.socket(url, options).connect().apply {
on(Socket.EVENT_CONNECT) {
Log.i("Canatoxxx", "OPEN: ${Socket.EVENT_CONNECT}")
trySend(CustomEvent.Connect)
}
io().apply {
on(Manager.EVENT_RECONNECT_FAILED) {
Log.i("Canatoxxx", "OPEN: ${Manager.EVENT_RECONNECT_FAILED}")
trySend(CustomEvent.ReconnectionFailed)
}
}
(...)
}
Thanks!
I will do some tests and maybe open a PR with documentation suggestions to make it more clear =D
First of all, thanks, @darrachequesne, for maintaining this lib. I know how hard it can be. If you open the sponsorship option, I would be happy to contribute.
Context
I'm trying to make my code react when there is a reconnection attempt. I considered listening to the manager events like I do with the socket ones. Didn't work.
I saw we had some active changes https://github.com/socketio/socket.io-client-java/issues/643, but I can't figure out how to use it.
Code
Something like this:
Logs
But my logs don't show the Manager events when I turn off and on the wifi.
Resume
This could be for one of two reasons:
Questions
Thank you in advance
Edit
Options