コード例 #1
0
ファイル: unauth.go プロジェクト: TF2Stadium/Helen
func (Unauth) LobbySpectatorJoin(so *wsevent.Client, args struct {
	ID *uint `json:"id"`
}) interface{} {

	lob, err := lobby.GetLobbyByID(*args.ID)

	if err != nil {
		return err
	}

	hooks.AfterLobbySpec(socket.UnauthServer, so, nil, lob)

	so.EmitJSON(helpers.NewRequest("lobbyData", lobby.DecorateLobbyData(lob, true)))

	return emptySuccess
}
コード例 #2
0
ファイル: lobby.go プロジェクト: TF2Stadium/Helen
func AfterLobbyJoin(so *wsevent.Client, lob *lobby.Lobby, player *player.Player) {
	room := fmt.Sprintf("%s_private", GetLobbyRoom(lob.ID))
	//make all sockets join the private room, given the one the player joined the lobby on
	//might close, so lobbyStart and lobbyReadyUp can be sent to other tabs
	sockets, _ := sessions.GetSockets(player.SteamID)
	for _, so := range sockets {
		socket.AuthServer.Join(so, room)
	}
	if lob.State == lobby.InProgress { // player is a substitute
		lob.AfterPlayerNotInGameFunc(player, 5*time.Minute, func() {
			// if player doesn't join game server in 5 minutes,
			// substitute them
			message := player.Alias() + " has been reported for not joining the game within 5 minutes"
			chat.SendNotification(message, int(lob.ID))
			lob.Substitute(player)
		})
	}

	broadcaster.SendMessage(player.SteamID, "lobbyJoined", lobby.DecorateLobbyData(lob, false))
}