let io_clone - io.clone();let _ = io.dyn_ns("/{client_id}", |s:SocketRef| asyncmove{let auth_token = s.ns().to_string();let namespace_size = io_clone.of(&auth_token[1..]).unwrap().sockets().unwrap().len();// pls help !!// ..........}); |
Answered by
Totodore
Jan 15, 2025
Replies: 1 comment 1 reply
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
If you want to get the number of sockets for this namespace variant: let _ = io.dyn_ns("/{client_id}", |s:SocketRef,io:SocketIo| asyncmove{let namespace_size = io.of(s.ns()).unwrap().sockets().unwrap().len();// this should work});But if you want all the sockets of all the namespaces variants corresponding to this dynamic namespace, you can't. Currently dynamic namespace features are quite limited. It will be added to the roadmap though. It is a bit hacky but can maintain an external counter or a set of the created namespaces and fetch + sum the number of sockets for each namespace. Btw you can use let _ = io.dyn_ns("/{client_id}", |s:SocketRef,io:SocketIo| asyncmove{let auth_token = s.ns().to_string();let namespace_size = io.of(&auth_token[1..]).unwrap().sockets().unwrap().len();// pls help !!// ..........}); |
1 reply
Answer selected bygovijr
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
If you want to get the number of sockets for this namespace variant:
But if you want all the sockets of all the namespaces variants corresponding to this dynamic namespace, you can't. Currently dynamic namespace features are quite limited. It will be added to the roadmap though.
It is a bit hacky but can maintain an external counter or a set of the created namespaces and fetch + sum the number of sockets for each namespace.
Btw you can use
SocketIoas a param extractor rather than cloning it: