예제 #1
0
        public AckListMessage(DatagramPacket dp)
        {
            this.dp   = dp;
            dpData    = dp.getData();
            ver       = ByteShortConvert.toShort(dpData, 0);
            sType     = ByteShortConvert.toShort(dpData, 2);
            connectId = ByteIntConvert.toInt(dpData, 4);
            clientId  = ByteIntConvert.toInt(dpData, 8);


            lastRead = ByteIntConvert.toInt(dpData, 4 + 8);
            int sum = ByteShortConvert.toShort(dpData, 8 + 8);

            ackList = new List <int>();
            int t = 0;

            for (int i = 0; i < sum; i++)
            {
                t = 10 + 4 * i;
                int sequence = ByteIntConvert.toInt(dpData, t + 8);
                ackList.Add(sequence);
            }
            ////#MLog.println("LLLLLLLLLLLLLL "+dp.getLength()+" "+ackList.size());
            t  = 10 + 4 * sum - 4;
            r1 = ByteIntConvert.toInt(dpData, t + 4 + 8);
            s1 = ByteIntConvert.toInt(dpData, t + 8 + 8);

            r2 = ByteIntConvert.toInt(dpData, t + 12 + 8);
            s2 = ByteIntConvert.toInt(dpData, t + 16 + 8);

            r3 = ByteIntConvert.toInt(dpData, t + 20 + 8);
            s3 = ByteIntConvert.toInt(dpData, t + 24 + 8);

            ////#MLog.println("aaaaaaaaa"+r3+"kkkkkkk "+s3);
        }
 public CloseMessage_Conn(DatagramPacket dp)
 {
     this.dp   = dp;
     dpData    = dp.getData();
     ver       = ByteShortConvert.toShort(dpData, 0);
     sType     = ByteShortConvert.toShort(dpData, 2);
     connectId = ByteIntConvert.toInt(dpData, 4);
     clientId  = ByteIntConvert.toInt(dpData, 8);
 }
예제 #3
0
 public PingMessage(DatagramPacket dp)
 {
     this.dp       = dp;
     dpData        = dp.getData();
     ver           = ByteShortConvert.toShort(dpData, 0);
     sType         = ByteShortConvert.toShort(dpData, 2);
     connectId     = ByteIntConvert.toInt(dpData, 4);
     clientId      = ByteIntConvert.toInt(dpData, 8);
     pingId        = ByteIntConvert.toInt(dpData, 12);
     downloadSpeed = ByteShortConvert.toShort(dpData, 16);
     uploadSpeed   = ByteShortConvert.toShort(dpData, 18);
 }
예제 #4
0
        public DataMessage(DatagramPacket dp)
        {
            this.dp = dp;
            dpData  = dp.getData();
            ver     = ByteShortConvert.toShort(dpData, 0);
            sType   = ByteShortConvert.toShort(dpData, 2);

            connectId = ByteIntConvert.toInt(dpData, 4);
            clientId  = ByteIntConvert.toInt(dpData, 8);

            sequence = ByteIntConvert.toInt(dpData, 12);
            length   = ByteShortConvert.toShort(dpData, 16);
            timeId   = ByteIntConvert.toInt(dpData, 18);
            data     = new byte[length];
            Array.Copy(dpData, 22, data, 0, length);
        }
예제 #5
0
        public void onReceivePacket(DatagramPacket dp)
        {
            byte[] dpData = dp.getData();
            int    sType  = 0;

            sType = MessageCheck.checkSType(dp);
            int remote_clientId = ByteIntConvert.toInt(dpData, 8);

            if (sType == MessageType.sType_PingMessage)
            {
                PingMessage pm = new PingMessage(dp);
                sendPingMessage2(pm.getPingId(), dp.getAddress(), dp.getPort());
                currentSpeed = pm.getDownloadSpeed() * 1024;
            }
            else if (sType == MessageType.sType_PingMessage2)
            {
                PingMessage2 pm = new PingMessage2(dp);
                lastReceivePingTime = DateTime.Now.Millisecond;
                long t = pingTable[pm.getPingId()];
                if (t != null)
                {
                    pingDelay = (int)(DateTime.Now.Millisecond - t);
                    String protocal = "";
                    if (route.isUseTcpTun())
                    {
                        protocal = "tcp";
                    }
                    else
                    {
                        protocal = "udp";
                    }
                    //MLog.println("    receive_ping222: "+pm.getPingId()+" "+new Date());
                    //MLog.println("delay_"+protocal+" "+pingDelay+"ms "+dp.getAddress().getHostAddress()+":"+dp.getPort());
                }
            }
        }