//其他客户端连接TransferServer处理
func connectTransferServer(session *link.Session, protoMsg systemProto.ProtoMsg) {
	rev_msg := protoMsg.Body.(*systemProto.System_ConnectTransferServerC2S)

	serverName := rev_msg.GetServerName()
	INFO(serverName + " Connect TransferServer")

	useServerName := strings.Split(serverName, "[")[0]
	sessions, exists := servers[useServerName]
	if !exists {
		sessions = make([]*link.Session, 0, 10)
	}
	sessions = append(sessions, session)
	servers[useServerName] = sessions

	//GameServer可以有多个
	if useServerName == "GameServer" {
		addr := strings.Split(session.Conn().RemoteAddr().String(), ":")
		addrIp := addr[0]
		addrPort, _ := strconv.Atoi(addr[1])
		gameConsistent.Add(hashs.NewNode(len(sessions), addrIp, addrPort, serverName, 1))
	}

	send_msg := systemProto.MarshalProtoMsg(&systemProto.System_ConnectTransferServerS2C{})
	systemProto.Send(send_msg, session)

	startDealReceiveMsgC2S(session)
}
Beispiel #2
0
//客户端连接DBServer使用
func connectDBServer(session *link.Session, protoMsg systemProto.ProtoMsg) {
	rev_msg := protoMsg.Body.(*systemProto.System_ConnectDBServerC2S)

	serverName := rev_msg.GetServerName()
	INFO(serverName + " Connect DBServer")
	serverName = strings.Split(serverName, "[")[0]
	servers[serverName] = session

	send_msg := systemProto.MarshalProtoMsg(&systemProto.System_ConnectDBServerS2C{})
	systemProto.Send(send_msg, session)
}
Beispiel #3
0
//发送连接DB服务器
func ConnectDBServer() {
	send_msg := systemProto.MarshalProtoMsg(&systemProto.System_ConnectDBServerC2S{
		ServerName: protos.String(global.ServerName),
	})
	systemProto.Send(send_msg, session)
}