Exemplo n.º 1
0
func AfterLobbyLeave(lobby *models.Lobby, player *models.Player) {
	broadcaster.SendMessage(player.SteamID, "lobbyLeft", models.DecorateLobbyLeave(lobby))

	sockets, _ := sessions.GetSockets(player.SteamID)
	//player might have connected from multiple tabs, remove all of them from the room
	for _, so := range sockets {
		socket.AuthServer.RemoveClient(so, fmt.Sprintf("%s_private", GetLobbyRoom(lobby.ID)))
	}
}
Exemplo n.º 2
0
func AfterLobbyJoin(so *wsevent.Client, lobby *models.Lobby, player *models.Player) {
	room := fmt.Sprintf("%s_private", GetLobbyRoom(lobby.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.AddClient(so, room)
	}

	broadcaster.SendMessage(player.SteamID, "lobbyJoined", models.DecorateLobbyData(lobby, false))
}
Exemplo n.º 3
0
func SendMessage(steamid string, event string, content interface{}) {
	sockets, ok := sessions.GetSockets(steamid)
	if !ok {
		return
	}

	for _, socket := range sockets {
		go func(so *wsevent.Client) {
			so.EmitJSON(helpers.NewRequest(event, content))
		}(socket)
	}
}
Exemplo n.º 4
0
func SendMessageSkipIDs(skipID, steamid, event string, content interface{}) {
	sockets, ok := sessions.GetSockets(steamid)
	if !ok {
		return
	}

	for _, socket := range sockets {
		if socket.ID != skipID {
			socket.EmitJSON(helpers.NewRequest(event, content))
		}
	}
}
Exemplo n.º 5
0
func AfterLobbyLeave(lob *lobby.Lobby, player *player.Player, kicked bool, notReady bool) {
	event := lobby.LobbyEvent{
		ID:       lob.ID,
		Kicked:   kicked,
		NotReady: notReady,
	}

	broadcaster.SendMessage(player.SteamID, "lobbyLeft", event)

	sockets, _ := sessions.GetSockets(player.SteamID)
	//player might have connected from multiple tabs, remove all of them from the room
	for _, so := range sockets {
		socket.AuthServer.Leave(so, fmt.Sprintf("%s_private", GetLobbyRoom(lob.ID)))
	}
}
Exemplo n.º 6
0
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))
}