/// <summary> /// /// </summary> /// <returns></returns> protected override Message.Message ReceiveMessage() { var msg = base.ReceiveMessage(); OnRecv?.Invoke(msg); return(msg); }
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); } }
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; } } }
protected void RecvHandler(ServerMsgEventArgs e) { OnRecv?.Invoke(this, e); }
protected void RecvHandler(ClientMsgEventArgs e) { OnRecv?.Invoke(this, e); }
public void Recv(IPacket packet) { OnRecv?.Invoke(packet); }