//发送连接TransferServer func sendConnectTransferServer() { INFO(global.ServerName + " Connect TransferServer ...") send_msg := protos.MarshalProtoMsg(&systemProto.System_ConnectTransferServerC2S{ ServerName: protos.String(global.ServerName), ServerID: protos.Uint32(global.ServerID), }) sendSystemMsgToServer(send_msg) }
func sendCommonLog(dir string, logType uint32, content string) { send_msg := protos.MarshalProtoMsg(&logProto.Log_CommonLogC2S{ Dir: protos.String(dir), Type: protos.Uint32(logType), Content: protos.String(content), Time: protos.Int64(time.Now().Unix()), }) sendLogMsgToServer(send_msg) }
//通知GameServer用户登录成功 func SetClientLoginSuccess(userName string, userID uint64, session *link.Session) { send_msg := protos.MarshalProtoMsg(&systemProto.System_ClientLoginSuccessC2S{ UserID: protos.Uint64(userID), UserName: protos.String(userName), SessionID: protos.Uint64(session.Id()), GameServerID: protos.Uint32(0), Network: protos.String(session.Conn().RemoteAddr().Network()), Addr: protos.String(session.Conn().RemoteAddr().String()), }) sendSystemMsgToServer(send_msg) }
//处理玩家登录成功,分配服务器 func clientLoginSuccess(session *link.Session, protoMsg protos.ProtoMsg) { rev_msg := protoMsg.Body.(*systemProto.System_ClientLoginSuccessC2S) //用户SessionID userSessionID := rev_msg.GetSessionID() //给该用户分配GameServer allotGameServer(userSessionID) //给该用户所分配的GameServerID gameServerID := getUserGameServerID(userSessionID) if gameServerID == 0 { return } //给该消息填充上所分配的GameServerID rev_msg.GameServerID = protos.Uint32(gameServerID) //通知GameServer用户登录成功 send_msg := protos.MarshalProtoMsg(rev_msg) sendSystemMsg2("GameServer", gameServerID, send_msg) }