當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。