Пример #1
0
        public static IClientMessage GetMessage(MessageReceivedEventArgs args)
        {
            ClientPacketHeader header = ClientPacketHeader.GetMessage(args);
            ClientPacketBody   body   = ClientPacketBody.GetMessage(ref header, args);

            return(new ClientPacketMessage(header, body, args.RemoteEP, args.LocalEP, args.LinqNo));
        }
Пример #2
0
 private ClientPacketMessage(ClientPacketHeader header, ClientPacketBody body, EndPoint remote, EndPoint local, long linkNo)
 {
     this.pHeader   = header;
     this.pBody     = body;
     this.pRemoteEP = remote;
     this.pLocalEP  = local;
     this.pLinkNo   = linkNo;
 }
Пример #3
0
        public static ClientPacketBody GetMessage(ref ClientPacketHeader header, MessageReceivedEventArgs args)
        {
            byte[] message = args.Buffer;
            int    offset  = sizeof(ClientPacketHeader); // 位于包头的偏移

            if (offset > message.Length)
            {
                return(null);
            }
            ClientPacketBody body = new ClientPacketBody();

            body.szBuffer    = message;                 // 客户端发过来的数据(客户端数据+网关包头)
            body.dwBufferOfs = offset;                  // 客户端数据开始索引
            body.szBufferLen = message.Length - offset; // 客户端数据长度
            return(body);
        }