/// <summary> /// 缓存接收到的信息并压入 队列中,等待主线程提取 /// </summary> public bool CacheMsg(byte[] cmd, int len) { revBuffer.Push(cmd, (uint)len); while (revBuffer.CheckOk()) { Message msg = NetTools.UnPackMessage(revBuffer.GetData()); revMsgQueue.Enqueue(msg); revBuffer.Pop(); } return(true); }
public void SendMessage(CmdNumber cmd, IExtensible data) { byte[] bytes = null; if (data != null) { MemoryStream mem = new MemoryStream(); #if USE_PROTODLL dto.Serialize(mem, cmd); #else Serializer.Serialize <IExtensible>(mem, data); #endif bytes = NetTools.MemoryStreamToBytes(mem, 0); } Message message = new Message(cmd, bytes); m_Processor.Send(message); }
/// <summary> /// 发送消息 /// </summary> public bool Send(Message msg) { byte[] cmd = NetTools.PackMesage(msg); return(socket.Send(cmd, cmd.Length)); }