Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override Message.Message ReceiveMessage()
        {
            var msg = base.ReceiveMessage();

            OnRecv?.Invoke(msg);
            return(msg);
        }
Пример #2
0
        private void procData(NetworkMgr.QueuePack pack)
        {
            while (true)
            {
                long nRecvLen = pack.buf.GetSize();
                int  headSize = ICD.HEADER.HeaderSize();
                if (nRecvLen < headSize)
                {
                    break;
                }

                byte[] headBuf = pack.buf.readSize(headSize);
                HEADER head    = new HEADER();
                head.Deserialize(ref headBuf);
                if (head.msgSOF != ICD.DEF.MAGIC_SOF)
                {
                    pack.buf.Clear();
                    break;
                }

                int msgSize = head.msgSize;
                if (nRecvLen < msgSize)
                {
                    break;
                }

                byte[] msgBuf = pack.buf.Pop(msgSize);

                HEADER msg = null;
                if (head.msgType == DEF.TYPE_REQ)
                {
                    msg = CreateICD_onServer(head);
                }
                else if (head.msgType == DEF.TYPE_REP)
                {
                    msg = CreateICD_onClient(head);
                }
                else
                {
                    LOG.warn();
                }

                msg.Deserialize(ref msgBuf);
                OnRecv?.Invoke(pack.ClientID, msg);
            }
        }
Пример #3
0
        private void OnRecvPacket(object sender, EventArgs e)
        {
            var queue = (ConcurrentQueue <NetworkMgr.QueuePack>)sender;

            while (true)
            {
                NetworkMgr.QueuePack pack = null;
                if (queue.TryDequeue(out pack))
                {
                    HEADER head = HEADER.GetHeaderInfo(pack.buf);
                    HEADER obj  = CreateIcdObject((COMMAND)head.id);
                    HEADER.Deserialize(obj, ref pack.buf);
                    OnRecv.Invoke(pack.ClientID, obj);
                }

                if (queue.IsEmpty)
                {
                    break;
                }
            }
        }
Пример #4
0
 protected void RecvHandler(ServerMsgEventArgs e)
 {
     OnRecv?.Invoke(this, e);
 }
Пример #5
0
 protected void RecvHandler(ClientMsgEventArgs e)
 {
     OnRecv?.Invoke(this, e);
 }
Пример #6
0
 public void Recv(IPacket packet)
 {
     OnRecv?.Invoke(packet);
 }