/// <summary> /// 把该结构转化成YueKaData用于通知客户端 /// </summary> /// <returns></returns> public YueKaData ToYueKaData() { YueKaData ykData = new YueKaData(); ykData.HasYueKa = HasYueKa == 1 ? true : false; ykData.CurrDay = CurDayOfPerYueKa(); ykData.AwardInfo = AwardInfo; ykData.RemainDay = RemainDayOfYueKa(); return(ykData); }
public static TCPProcessCmdResults ProcessGetYueKaData(TCPManager tcpMgr, TMSKSocket socket, TCPClientPool tcpClientPool, TCPRandKey tcpRandKey, global::Server.Protocol.TCPOutPacketPool pool, int nID, byte[] data, int count, out global::Server.Protocol.TCPOutPacket tcpOutPacket) { //*/ /* * //*/ tcpOutPacket = null; string cmdData = null; string[] fields = null; try { cmdData = new UTF8Encoding().GetString(data, 0, count); } catch (Exception) { LogManager.WriteLog(LogTypes.Error, string.Format("解析指令字符串错误, CMD={0}, Client={1}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket))); return(TCPProcessCmdResults.RESULT_FAILED); } try { fields = cmdData.Split(':'); if (1 != fields.Length) { LogManager.WriteLog(LogTypes.Error, string.Format("指令参数个数错误, CMD={0}, Client={1}, Recv={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), fields.Length)); return(TCPProcessCmdResults.RESULT_FAILED); } int roleID = Convert.ToInt32(fields[0]); GameClient client = GameManager.ClientMgr.FindClient(socket); if (null == client || client.ClientData.RoleID != roleID) { LogManager.WriteLog(LogTypes.Error, string.Format("根据RoleID定位GameClient对象失败, CMD={0}, Client={1}, RoleID={2}", (TCPGameServerCmds)nID, Global.GetSocketRemoteEndPoint(socket), roleID)); return(TCPProcessCmdResults.RESULT_FAILED); } YueKaData ykData = null; lock (client.ClientData.YKDetail) { ykData = client.ClientData.YKDetail.ToYueKaData(); } GameManager.ClientMgr.SendToClient(client, DataHelper.ObjectToBytes <YueKaData>(ykData), nID); return(TCPProcessCmdResults.RESULT_OK); } catch (Exception ex) { DataHelper.WriteFormatExceptionLog(ex, "ProcessGetYueKaData", false); } return(TCPProcessCmdResults.RESULT_DATA); }