Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(socketioxide): disconnect handler #41

Merged
merged 24 commits into from
Sep 17, 2023
Merged

Conversation

Totodore
Copy link
Owner

@Totodore Totodore commented Jun 30, 2023

Currently there is no way for the end user to execute code when the socket is disconnected.

Now, it will be possible to add an handler executed when the socket is disconnected:

  • Gracefully from the server
  • Gracefully from the client
  • When the transport closed or crashed

There will be a DisconnectReason enum provided so the user knows what caused the disconnect event.

Steps :

  • on_disconnect handler on socketioxide Socket.
  • DisconnectReason on engineioxide
  • DisconnectReason on socketioxide
  • Errors provided for TransportError variant on the DisconnectReason

@Totodore Totodore added the enhancement New feature or request label Jun 30, 2023
socketioxide/src/client.rs Fixed Show fixed Hide fixed
socketioxide/src/socket.rs Fixed Show fixed Hide fixed
socketioxide/src/socket.rs Fixed Show fixed Hide fixed
socketioxide/src/client.rs Fixed Show fixed Hide fixed
socketioxide/src/client.rs Fixed Show fixed Hide fixed
socketioxide/src/client.rs Fixed Show fixed Hide fixed
socketioxide/src/client.rs Fixed Show fixed Hide fixed
socketioxide/src/client.rs Fixed Show fixed Hide fixed
socketioxide/src/client.rs Fixed Show fixed Hide fixed
@Totodore Totodore changed the title Feature: disconnect handler feat(socketioxide/adapters): disconnect handler Jul 29, 2023
@Totodore Totodore changed the title feat(socketioxide/adapters): disconnect handler feat(socketioxide): disconnect handler Jul 29, 2023
@lscobe16
Copy link

lscobe16 commented Aug 6, 2023

Is there currently (in version 0.3.0) at least a way to check, whether a given socket is open or closed? (I don't see any.)
I see that there is a way on the main branch (e.g. trying to send and using the returned result), but that is not yet released onto crates.io. When do you plan to release the next version?

@Totodore
Copy link
Owner Author

Totodore commented Aug 6, 2023

I plan to release it as soon as PRs #59, #56 and this one are merged

socketioxide/src/client.rs Fixed Show fixed Hide fixed
);
socket.close();
let reason: Option<EIoDisconnectReason> = err.into();
reason.map(|reason| socket.close(reason));

Check warning

Code scanning / clippy

called map(f) on an Option value where f is a closure that returns the unit type () Warning

called map(f) on an Option value where f is a closure that returns the unit type ()
@Totodore Totodore merged commit 24fd5e3 into main Sep 17, 2023
8 checks passed
@Totodore Totodore deleted the ft-disconnect-handler branch September 19, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants