Remove session after rejoin few times

This commit is contained in:
giongto35 2019-05-04 01:52:05 +08:00
parent 485b30389d
commit 401940b717
9 changed files with 105 additions and 20 deletions

View file

@ -94,11 +94,13 @@ func (s *Session) RegisterBrowserClient() {
// Create new room
// TODO: check if roomID is in the current server
room := s.handler.getRoom(s.RoomID)
log.Println("Got Room from local ", room, " ID: ", s.RoomID)
if room == nil {
room = s.handler.createNewRoom(s.GameName, s.RoomID, s.PlayerIndex)
}
// Attach peerconnection to room
s.handler.detachPeerConn(s.peerconnection)
room.AddConnectionToRoom(s.peerconnection, s.PlayerIndex)
s.RoomID = room.ID