本文整理汇总了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)
}