thruster-rs/thruster-socketio

the socket.rooms() is incorrect

Closed this issue · 1 comments

Hi @trezm
There are some test code:

#[socketio_listener]
async fn join_room(mut socket: SocketIO, value: String) -> Result<(), ()> {
    socket.join(&value).await;

    debug!("join socket rooms size = {}, rooms = {:?}", socket.rooms().len(), socket.rooms());
   ...
  }

when I first called the function join_room, the log is:

021-06-23T17:17:33.924201400+10:00 DEBUG socketio::socketio::socketio - join socket rooms size = 0, rooms = []
2021-06-23T17:17:33.924687600+10:00 DEBUG socketio::socketio::socketio - Sockt(irBGXHhQVqIzruWCIgYZMYFh1zux8N) create new room(aaa).

But there is one room "aaa", rooms().len() is 1, not 0.

Would you like take a look at this.

Thanks.

Another issue, when one socket joined the same room twice, there are two sockets/channels in the room. But I think, the socket in one room is unique. Is it correct?

2021-06-23T18:09:48.400076100+10:00 DEBUG socketio::socketio::socketio - room aaa have sockets number is 2
2021-06-23T18:09:48.400392400+10:00 DEBUG socketio::socketio::socketio - in a room aaa,  joined socket id = 6ZiTvNSgZuwHLcLDNPk8Vpv0HXXctm
2021-06-23T18:09:48.400749600+10:00 DEBUG socketio::socketio::socketio - in a room aaa,  joined socket id = 6ZiTvNSgZuwHLcLDNPk8Vpv0HXXctm