当前位置: 首页>>代码示例>>Golang>>正文


Golang Server.AddClient方法代码示例

本文整理汇总了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))
}
开发者ID:demipixel,项目名称:Helen,代码行数:7,代码来源:playerHelpers.go

示例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)
}
开发者ID:gpittarelli,项目名称:Helen,代码行数:12,代码来源:lobby.go

示例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()))
}
开发者ID:gpittarelli,项目名称:Helen,代码行数:14,代码来源:player.go

示例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)))
}
开发者ID:demipixel,项目名称:Helen,代码行数:21,代码来源:playerHelpers.go

示例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)
}
开发者ID:demipixel,项目名称:Helen,代码行数:4,代码来源:playerHelpers.go


注:本文中的github.com/TF2Stadium/wsevent.Server.AddClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。