private void OnQueryIndividualResp(Packet packet) { ByteBuffer buffer = ByteBufferPool.PopPacket(packet.Data); //不需要只包含用户信息的数据包 buffer.Position = Marshal.SizeOf(typeof(CMD_GP_UserIndividual)); var info = new CMD_GH_UserInformation(); info.dwLogoID = GameApp.GameData.UserInfo.HeadId; while (true) { string str = ""; ushort type = ProtoHelper.ReadDescDataString(ref buffer, ref str); if (type == 0) { break; } switch (type) { case CommonDefine.DTP_GP_UI_COMPELLATION: { info.dwName = str; break; } case CommonDefine.DTP_GP_UI_QQ: { info.dwIM = str; break; } case CommonDefine.DTP_GP_UI_USER_NOTE: { info.dwIdentification = str; break; } case CommonDefine.DTP_GP_UI_MOBILE_PHONE: { info.dwCellPhone = str; break; } } } ByteBufferPool.DropPacket(buffer); GameApp.Account.CallUserInformationEvent( info.dwName, info.dwIdentification, info.dwCellPhone, info.dwIM, info.dwLogoID); }
private void AnalysisVersionInfo(Packet packet) { ByteBuffer buffer = ByteBufferPool.PopPacket(packet.Data); //不需要只包含用户信息的数据包 byte[] descData = buffer.PopByteArray(Marshal.SizeOf(typeof(CMD_GP_ClientUpdate))); CMD_GP_ClientUpdate version = GameConvert.ByteToStruct <CMD_GP_ClientUpdate>(descData); while (true) { string str = ""; ushort type = ProtoHelper.ReadDescDataString(ref buffer, ref str); if (type == 0) { break; } switch (type) { case CommonDefine.DTP_GP_CDN: { GameApp.GameData.CDN = str; break; } case CommonDefine.DTP_GP_OFFICESITE_URL: { GameApp.GameData.OfficeSiteUrl = str; break; } case CommonDefine.DTP_GP_BACK_STORGE_URL: { GameApp.GameData.BackStorgeUrl = str; break; } case CommonDefine.DTP_GP_MODULE_INFO: { GameApp.ModuleMgr.ApplyDataFromStr(str); break; } } } ByteBufferPool.DropPacket(buffer); GameApp.Account.CallVersionInfoEvent(version.dwVersion); }
private void OnUserEnterResp(Packet packet) { int dataStruct = Marshal.SizeOf(typeof(tagUserInfoHead)); if (packet.DataSize < dataStruct) { Debug.LogWarning("data error!"); return; } tagUserInfoHead userInfo = GameConvert.ByteToStruct <tagUserInfoHead>(packet.Data); PlayerInfo player = ProtoHelper.InitPlayerInfo(userInfo); if (player.ID == GameApp.GameData.UserInfo.UserID) { GameApp.GameData.UserInfo.SetSitInfo(player.DeskNO, player.DeskStation); } ByteBuffer buffer = ByteBufferPool.PopPacket(packet.Data); buffer.Position = dataStruct; while (true) { string str = ""; ushort type = ProtoHelper.ReadDescDataString(ref buffer, ref str); if (type == 0) { break; } switch (type) { case CommonDefine.DTP_GR_NICK_NAME: { player.NickName = str; break; } } } ByteBufferPool.DropPacket(buffer); GameApp.GameSrv.AddPlayer(player); GameApp.GameSrv.CallUserEnterEvent(player); }
void OnLogonSuccess(Packet packet) { int dataStruct = Marshal.SizeOf(typeof(CMD_GP_LogonSuccess)); com.QH.QPGame.GameUtils.Logger.Net.Log("logon success. size:" + packet.DataSize + "/" + dataStruct); if (packet.DataSize < dataStruct) { com.QH.QPGame.GameUtils.Logger.Net.LogError(" CMD_GP_LogonSuccess data error!"); return; } ByteBuffer buffer = ByteBufferPool.PopPacket(packet.Data); byte[] descData = buffer.PopByteArray(Marshal.SizeOf(typeof(CMD_GP_LogonSuccess))); CMD_GP_LogonSuccess loginData = GameConvert.ByteToStruct <CMD_GP_LogonSuccess>(descData); GameApp.GameData.UserInfo = ProtoHelper.InitUserInfo(loginData); com.QH.QPGame.GameUtils.Logger.Net.Log("User:"******" Loged|Money:" + loginData.lUserScore + "|Bank:" + loginData.lUserInsure); while (true) { string str = ""; ushort type = ProtoHelper.ReadDescDataString(ref buffer, ref str); if (type == 0) { break; } switch (type) { case CommonDefine.DTP_GP_UI_UNDER_WRITE: { GameApp.GameData.UserInfo.UnderWrite = str; break; } } } ByteBufferPool.DropPacket(buffer); GameApp.Account.CallLogonSuccessEvent(); }
public void OnServerListResp(Packet packet) { switch (packet.SubCmd) { case SubCommand.SUB_GP_LIST_TYPE: { int dataStruct = Marshal.SizeOf(typeof(tagGameType)); if (packet.DataSize < dataStruct) { com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameType Game List data error!"); return; } int dataSzie = Marshal.SizeOf(typeof(tagGameType)); int dataCount = packet.DataSize / dataSzie; ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data); for (int i = 0; i < dataCount; i++) { byte[] tempDataBB = listDataBuff.PopByteArray(dataSzie); tagGameType kindDataE = GameConvert.ByteToStruct <tagGameType>(tempDataBB); GameApp.GameListMgr.AppendTypeItem(ProtoHelper.InitGameTypeItem(kindDataE)); //Logger.Sys.Log("Append Game Type===========" + kindDataE.TypeID + " Name:" + kindDataE.TypeName); } ByteBufferPool.DropPacket(listDataBuff); return; } case SubCommand.SUB_GP_LIST_KIND: { int dataStruct = Marshal.SizeOf(typeof(tagGameKind)); if (packet.DataSize < dataStruct) { com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameKind Game name list data error!"); return; } int dataSzie = Marshal.SizeOf(typeof(tagGameKind)); int dataCount = packet.DataSize / dataSzie; ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data); for (int i = 0; i < dataCount; i++) { byte[] tempDataBB = listDataBuff.PopByteArray(dataSzie); tagGameKind tempNameS = GameConvert.ByteToStruct <tagGameKind>(tempDataBB); GameApp.GameListMgr.AppendKindItem(ProtoHelper.InitGameKindItem(tempNameS)); //Logger.Sys.Log("Append Game Kind==========="+ tempNameS.KindID +" Name:"+tempNameS.KindName + " Process:"+tempNameS.ProcessName); } ByteBufferPool.DropPacket(listDataBuff); //GameApp.Account.CallGameListFinishEvent(); return; } case SubCommand.SUB_GP_LIST_NODE: { int dataStruct = Marshal.SizeOf(typeof(tagGameNode)); if (packet.DataSize < dataStruct) { com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameNode Game List data error!"); return; } int dataSzie = Marshal.SizeOf(typeof(tagGameNode)); int dataCount = packet.DataSize / dataSzie; ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data); for (int i = 0; i < dataCount; i++) { byte[] tempDataBB = listDataBuff.PopByteArray(dataSzie); tagGameNode nodeDataE = GameConvert.ByteToStruct <tagGameNode>(tempDataBB); GameApp.GameListMgr.AppendNodeItem(ProtoHelper.InitGameNodeItem(nodeDataE)); } ByteBufferPool.DropPacket(listDataBuff); GameApp.Account.CallGameListFinishEvent(); return; } case SubCommand.SUB_GP_LIST_SERVER: { int dataStruct = Marshal.SizeOf(typeof(tagGameServer)); if (packet.DataSize < dataStruct) { com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameServer Room list data error!"); return; } uint kindID = 0; int dataSzie = Marshal.SizeOf(typeof(tagGameServer)); int dataCount = packet.DataSize / dataSzie; ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data); for (int i = 0; i < dataCount; i++) { byte[] tempData = listDataBuff.PopByteArray(dataSzie); tagGameServer roomInfoS = GameConvert.ByteToStruct <tagGameServer>(tempData); //Logger.Net.Log("--------------ROOM:" + roomInfoS.KindID + " " + roomInfoS.ServerID + " " + roomInfoS.ServerName+" "+roomInfoS.ServerAddr); kindID = roomInfoS.KindID; GameApp.GameListMgr.AppendRoomItem(ProtoHelper.InitGameRoomItem(roomInfoS)); /* if (GameApp.GameData.ReEnter && * GameApp.GameData.ReEnterRoomID == roomInfoS.ServerID) * { * GameApp.GameData.ReEnterNameID = roomInfoS.KindID; * if (ReconnectGameEvent != null) * { * ReconnectGameEvent(roomInfoS.ServerID, false); * } * }*/ } ByteBufferPool.DropPacket(listDataBuff); GameApp.Account.CallRoomListFinishEvent(kindID); return; } case SubCommand.SUB_CS_S_SERVER_ONLINE: { int dataSzie = Marshal.SizeOf(typeof(tagOnLineInfoServer)); if (packet.DataSize < dataSzie) { com.QH.QPGame.GameUtils.Logger.Net.LogError(" tagGameServer Room list data error! size:" + packet.DataSize); return; } int dataCount = packet.DataSize / dataSzie; ByteBuffer listDataBuff = ByteBufferPool.PopPacket(packet.Data); for (int i = 0; i < dataCount; i++) { byte[] tempDataBB = listDataBuff.PopByteArray(dataSzie); tagOnLineInfoServer OnlineDataE = GameConvert.ByteToStruct <tagOnLineInfoServer>(tempDataBB); SGameRoomItem temRoomItem = GameApp.GameListMgr.FindRoomItem((uint)OnlineDataE.wServerID); if (temRoomItem != null) { temRoomItem.UpdateOnlineCnt((uint)OnlineDataE.dwOnLineCount); } } ByteBufferPool.DropPacket(listDataBuff); GameApp.Account.CallOnlineCountEvent(); return; } } }