示例#1
0
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)
}
示例#2
0
文件: lobby.go 项目: TF2Stadium/Helen
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)
}