func AfterLobbySpec(server *wsevent.Server, so *wsevent.Client, lobby *models.Lobby) { //remove socket from room of the previous lobby the socket was spectating (if any) lobbyID, ok := sessions.GetSpectating(so.ID) if ok { server.RemoveClient(so, fmt.Sprintf("%d_public", lobbyID)) sessions.RemoveSpectator(so.ID) } server.AddClient(so, fmt.Sprintf("%s_public", GetLobbyRoom(lobby.ID))) chelpers.BroadcastScrollback(so, lobby.ID) sessions.SetSpectator(so.ID, lobby.ID) }
func AfterLobbySpec(server *wsevent.Server, so *wsevent.Client, player *player.Player, lob *lobby.Lobby) { //remove socket from room of the previous lobby the socket was spectating (if any) lobbyID, ok := sessions.GetSpectating(so.ID) if ok { server.Leave(so, fmt.Sprintf("%d_public", lobbyID)) sessions.RemoveSpectator(so.ID) if player != nil { prevLobby, _ := lobby.GetLobbyByID(lobbyID) prevLobby.RemoveSpectator(player, true) } } server.Join(so, fmt.Sprintf("%d_public", lob.ID)) chelpers.BroadcastScrollback(so, lob.ID) sessions.SetSpectator(so.ID, lob.ID) }