Esempio n. 1
0
 void notifyReceived(Object object) {
   if (object instanceof Ping) {
     Ping ping = (Ping) object;
     if (ping.isReply) {
       if (ping.id == lastPingID - 1) {
         returnTripTime = (int) (System.currentTimeMillis() - lastPingSendTime);
         if (TRACE) trace("kryonet", this + " return trip time: " + returnTripTime);
       }
     } else {
       ping.isReply = true;
       sendTCP(ping);
     }
   }
   Listener[] listeners = this.listeners;
   for (int i = 0, n = listeners.length; i < n; i++) listeners[i].received(this, object);
 }
Esempio n. 2
0
 /**
  * Requests the connection to communicate with the remote computer to determine a new value for
  * the {@link #getReturnTripTime() return trip time}. When the connection receives a {@link
  * FrameworkMessage.Ping} object with {@link Ping#isReply isReply} set to true, the new return
  * trip time is available.
  */
 public void updateReturnTripTime() {
   Ping ping = new Ping();
   ping.id = lastPingID++;
   lastPingSendTime = System.currentTimeMillis();
   sendTCP(ping);
 }