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

Transport type and Protocol Version info for Socket #180

Merged
merged 4 commits into from
Nov 26, 2023
Merged

Conversation

Totodore
Copy link
Owner

@Totodore Totodore commented Nov 26, 2023

Adds the following function to the Socket struct:

  • transport_type to get the current TransportType of the socket
  • protocol to get the current ProtocolVersion of the socket in the case of multiple protocols enabled

Now handler extractors are implemented for TransportType and ProtocolVersion so now it is possible to use them as Handler arguments:

use socketioxide::{SocketIo, TransportType, ProtocolVersion, extract::*};

let (_, io) = SocketIo::new_svc();
io.ns("/", |socket: SocketRef, transport: TransportType| {
    assert_eq!(socket.transport_type(), transport);
});

io.ns("/", |socket: SocketRef, protocol: ProtocolVersion| {
    assert_eq!(socket.protocol(), transport);
});

Fix issue #177

@Totodore Totodore linked an issue Nov 26, 2023 that may be closed by this pull request
@Totodore Totodore changed the title Feat: Transport type and Protocol Version info for Socket Transport type and Protocol Version info for Socket Nov 26, 2023
@Totodore Totodore merged commit e352b42 into main Nov 26, 2023
14 checks passed
@Totodore Totodore deleted the ft-transport-type branch November 26, 2023 19:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Get the current transport type of the socket
1 participant