Esempio n. 1
0
// 发送数据给玩家
// playerList:玩家列表
// responseObj:Socket服务器的返回对象
func SendToPlayer(playerList []*player.Player, responseObj *responseDataObject.SocketResponseObject) {
	for _, item := range playerList {
		if item.ClientId > 0 {
			if clientObj, ok := clientBLL.GetClient(item.ClientId); ok {
				responseResult(clientObj, responseObj)
			}
		}
	}
}
Esempio n. 2
0
// 根据玩家对象来断开客连接
// 注销客户端连接
// 从缓存中移除玩家对象
// playerObj:玩家对象
// playerDisconnectType:玩家断开连接的类型
func disconnectByPlayer(playerObj *player.Player, playerDisconnectType disconnectType.PlayerDisconnectType) {
	// 断开客户端连接
	if playerObj.ClientId > 0 {
		if clientObj, ok := clientBLL.GetClient(playerObj.ClientId); ok {
			switch playerDisconnectType {
			case disconnectType.FromForbid:
				SendForbidMsg(clientObj)
			}
		}
	}

	// 将玩家从缓存中移除
	UnRegisterPlayer(playerObj)
}