Exemplo n.º 1
0
        public Msg ResolveToMessage(byte[] buffer, IPEndPoint remoteEndPoint)
        {
            if (buffer == null || buffer.Length < 0)
            {
                return(null);
            }
            Msg m = null;

            if (MessagePacker.Test(buffer))
            {
                PacketNetWorkMsg pack = MessagePacker.Parse(buffer, remoteEndPoint);
                if (pack == null)
                {
                    return(null);
                }
                if (DetermineConfirm(pack))
                {
                    //发送确认标志
                    Msg cm = Helper.CreateRecivedCheck(remoteEndPoint, pack.PackageNo, pack.PackageIndex, _config);
                    Client.SendMsg(cm);
                }
                m = MessagePacker.TryToTranslateMessage(pack);
            }
            return(m);
        }
Exemplo n.º 2
0
        private void button3_Click(object sender, EventArgs e)
        {
            IPEndPoint host   = new IPEndPoint(IPAddress.Any, 8888);
            IPEndPoint remote = new IPEndPoint(IPAddress.Any, 7777);
            Msg        m      = new Msg(remote, "zz", "zhujun", Commands.Entry, "test1", "test2");

            m.PackageNo = 12345678;
            PacketNetWorkMsg[] udps = MessagePacker.BuildNetworkMessage(m);
            PacketNetWorkMsg   p    = MessagePacker.Parse(udps[0].Data, null);
            Msg ms = MessagePacker.TryToTranslateMessage(p);
        }