本文整理匯總了Golang中github.com/TF2Stadium/wsevent.Server.AddClient方法的典型用法代碼示例。如果您正苦於以下問題:Golang Server.AddClient方法的具體用法?Golang Server.AddClient怎麽用?Golang Server.AddClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/TF2Stadium/wsevent.Server
的用法示例。
在下文中一共展示了Server.AddClient方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: AfterLobbyJoin
func AfterLobbyJoin(server *wsevent.Server, so *wsevent.Client, lobby *models.Lobby, player *models.Player) {
room := fmt.Sprintf("%s_private", GetLobbyRoom(lobby.ID))
server.AddClient(so, room)
bytes, _ := json.Marshal(models.DecorateLobbyData(lobby, false))
broadcaster.SendMessage(player.SteamId, "lobbyJoined", string(bytes))
}
示例2: AfterLobbySpec
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)
}
示例3: AfterConnect
func AfterConnect(server *wsevent.Server, so *wsevent.Client) {
server.AddClient(so, fmt.Sprintf("%s_public", config.GlobalChatRoom)) //room for global chat
var lobbies []models.Lobby
err := db.DB.Where("state = ?", models.LobbyStateWaiting).Order("id desc").Find(&lobbies).Error
if err != nil {
logrus.Error(err)
return
}
so.EmitJSON(helpers.NewRequest("lobbyListData", models.DecorateLobbyListData(lobbies)))
chelpers.BroadcastScrollback(so, 0)
so.EmitJSON(helpers.NewRequest("subListData", models.DecorateSubstituteList()))
}
示例4: AfterConnect
func AfterConnect(server *wsevent.Server, so *wsevent.Client) {
server.AddClient(so, fmt.Sprintf("%s_public", config.Constants.GlobalChatRoom)) //room for global chat
var lobbies []models.Lobby
err := db.DB.Where("state = ?", models.LobbyStateWaiting).Order("id desc").Find(&lobbies).Error
if err != nil {
helpers.Logger.Critical("%s", err.Error())
return
}
bytes, _ := json.Marshal(models.DecorateLobbyListData(lobbies))
if err != nil {
helpers.Logger.Critical("Failed to send lobby list: %s", err.Error())
return
}
so.EmitJSON(helpers.NewRequest("lobbyListData", string(bytes)))
BroadcastScrollback(so, 0)
bytes, _ = json.Marshal(helpers.NewRequestFromObj("subListData", models.GetSubList()))
so.EmitJSON(helpers.NewRequest("subListData", string(bytes)))
}
示例5: AfterLobbySpec
func AfterLobbySpec(server *wsevent.Server, so *wsevent.Client, lobby *models.Lobby) {
server.AddClient(so, fmt.Sprintf("%s_public", GetLobbyRoom(lobby.ID)))
BroadcastScrollback(so, lobby.ID)
}