-
Notifications
You must be signed in to change notification settings - Fork 76
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
How to join/leave a socket.io room #40
Comments
Hi, thanks for using the crate! You're right, there are no functions concerning rooms, but that's because this crate currently only implements the client and rooms is a fully server side feature. That means managing rooms in any way is done on the server side, a client does not have any information about which room he's in or even which rooms exist on the server side. For further reading visit the official socket.io documentation. An example using this client would look something like this: server code// assume you've set up the server somehow
io.on('connection', function(socket) {
// you can join (leave) a room by calling the join (leave) method
socket.on('room', function(room) {
socket.join(room);
});
});
// this emits to all clients in the room
io.sockets.in("room1").emit('message', 'what is going on, party people?'); client codeuse serde_json::json;
// ...
// assume you've connected the client and defined callbacks for certain events
let payload = json!("room1");
socket.emit("room", payload).expect("Server unreachable"); |
I see, rust-socketio is only a client crate. Thanks a lot. @1c3t3a |
Do you have any plan to implement socketio server side features? |
Actually yes, there is a tracking issue for this (#32). I will tackle it as soon as possible, but if you're interested, feel free to implement it ;) |
Hi there,
I am studying the rust-socketio crate. In my case, I need to join a socket.io room and leave this room when something happened,
so I want to known, how to join and leave a special socket.io room, I didn't found the rust functions.
Thanks for a lot.
The text was updated successfully, but these errors were encountered: