Exemplo n.º 1
0
 public void onReceivePing(PingMessage pm)
 {
     if (route.mode == 2)
     {
         currentSpeed = pm.getDownloadSpeed() * 1024;
         //#MLog.println("更新对方速度: "+currentSpeed);
     }
 }
Exemplo n.º 2
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());
                }
            }
        }