private static bool _SampleMsgCreater(UInt16 id, ref CSLib.Framework.CMessage msg) { Message.EMsgID msgID = (Message.EMsgID)id; switch (msgID) { case Message.EMsgID.EMID_SAMPLE_NTF_OK: { msg = new Message.CMsgSampleNtfOk(); return(true); } case Message.EMsgID.EMID_SAMPLE_REQ_SAY: { msg = new Message.CMsgSampleReqSay(); return(true); } case Message.EMsgID.EMID_SAMPLE_RES_SAY: { msg = new Message.CMsgSampleResSay(); return(true); } } return(false); }
// private void _OnMsgTestReqSay(CSLib.Framework.CMessageLabel msgLabel, CSLib.Framework.CMessage msg) { Message.CMsgSampleReqSay reqSay = (Message.CMsgSampleReqSay)msg; Console.WriteLine("收到:" + reqSay.m_string + "{" + m_netStub.LocalIPEndPoint.ToString() + "<---" + m_netStub.PeerIPEndPoint.ToString() + "}"); Message.CMsgSampleResSay resSay = new Message.CMsgSampleResSay(); resSay.m_string = "Sever No.["; resSay.m_string += m_number.ToString(); resSay.m_string += "]"; resSay.m_bool = reqSay.m_bool; resSay.m_byte = reqSay.m_byte; resSay.m_bytes = reqSay.m_bytes; resSay.m_double = reqSay.m_double; resSay.m_float = reqSay.m_float; resSay.m_int = reqSay.m_int; resSay.m_long = reqSay.m_long; resSay.m_short = reqSay.m_short; resSay.m_uint = reqSay.m_uint; resSay.m_ulong = reqSay.m_ulong; resSay.m_ushort = reqSay.m_ushort; m_number++; CSLib.Utility.CStream streamRes = new CSLib.Utility.CStream(); resSay.Serialize(streamRes); m_netStub.SendAsync(streamRes); }
private void _OnMsgTestResSay(CSLib.Framework.CMessageLabel msgLabel, CSLib.Framework.CMessage msg) { Message.CMsgSampleResSay resSay = (Message.CMsgSampleResSay)msg; Console.WriteLine("收到:" + resSay.m_string + resSay.m_bool + " " + resSay.m_byte + " " + resSay.m_bytes[0] + " " + resSay.m_bytes[1] + " " + resSay.m_bytes[2] + " " + resSay.m_bytes[3] + " " + resSay.m_bytes[4] + " " + resSay.m_double + " " + resSay.m_float + " " + resSay.m_int + " " + resSay.m_long + " " + resSay.m_short + " " + resSay.m_uint + " " + resSay.m_ulong + " " + resSay.m_ushort); }