Exemplo n.º 1
0
func (Player) PlayerRecentLobbies(so *wsevent.Client, args struct {
	SteamID *string `json:"steamid"`
	Lobbies *int    `json:"lobbies"`
	LobbyID int     `json:"lobbyId"` // start from this lobbyID, 0 when not specified in json
}) interface{} {
	var p *player.Player

	if *args.SteamID != "" {
		var err error
		p, err = player.GetPlayerBySteamID(*args.SteamID)
		if err != nil {
			return err
		}

	} else {
		p = chelpers.GetPlayer(so.Token)
	}

	var lobbies []*lobby.Lobby

	db.DB.Model(&lobby.Lobby{}).Joins("INNER JOIN lobby_slots ON lobbies.ID = lobby_slots.lobby_id").
		Where("lobbies.match_ended = TRUE and lobby_slots.player_id = ? AND lobby_slots.needs_sub = FALSE AND lobbies.ID >= ?", p.ID, args.LobbyID).
		Order("lobbies.id desc").
		Limit(*args.Lobbies).
		Find(&lobbies)

	return newResponse(lobby.DecorateLobbyListData(lobbies, true))
}
Exemplo n.º 2
0
func (Lobby) RequestLobbyListData(so *wsevent.Client, _ struct{}) interface{} {
	so.EmitJSON(helpers.NewRequest("lobbyListData", lobby.DecorateLobbyListData(lobby.GetWaitingLobbies(), false)))

	return emptySuccess
}