public void Decode <T>(IByteArrayReader reader, out object value) where T : new()
        {
            Int32 valueEx = 0;

            reader.ReadI32(ref valueEx);
            value = valueEx;
        }
        public void Decode <T>(IByteArrayReader reader, out object value) where T : new()
        {
            value = new T();
            MessageBase valueEx = value as MessageBase;

            if (valueEx == null)
            {
                throw new NullReferenceException("转换为空");
            }
            valueEx.UnPackMsg(reader);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 处理消息
        /// 在socket线程处理
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="msgLen"></param>
        private void ProcessMsg(IByteArrayReader reader, int msgLen)
        {
            UInt16 msgId = 0;

            reader.ReadU16(ref msgId);
            if (msgId < 1)
            {
                mLogger.LogError("msgID = " + msgId + ", msgID < 1", "ProcessMsg");
                return;
            }

            if (MsgTransferLog)
            {
                mLogger.LogInfo("rev msg, msgId=" + GetMessageTypeString(msgId), "ProcessMsg");
            }

            IMessage msg = mMsgPool.GetMsgInst(msgId);

            if (msg == null)
            {
                mLogger.LogWarning("MsgPool is not find the msg, msgId = " + msgId, "ProcessMsg");
                return;
            }

            if (RecodeDump)
            {
                ActorCmd dumpCmd = new ActorCmd(NetworkOutCmd.Dump)
                {
                    Param0 = (uint)msgId,
                    Param1 = msgLen,
                    Param2 = reader.Dump(),
                };
                SendToOutput(dumpCmd);
            }

            try
            {
                msg.MergeFrom(reader.GetStream());
            }
            catch (Exception e)
            {
                mLogger.LogError("msgID = " + msgId + ", MergeFrom error, " + e.Message, "ProcessMsg");
                return;
            }

            SendToOutput(new ActorCmd(NetworkOutCmd.Message, msg));
        }
Exemplo n.º 4
0
 /// <summary>
 /// 解消息包
 /// </summary>
 /// <param name="reader"></param>
 public virtual void UnPackMsg(IByteArrayReader reader)
 {
 }