Ejemplo n.º 1
0
 public void tryToConnect(int timeout_ms)
 {
     // TODO [x] : This is evil as it blocks the main graphics thread
     //     should refactor nt into a co-routine? to not block in this way...
     Debug.Log("Trying to connect to : " + decoderAddress);
     // TODO [] : Add a user query if the connection doesn't work for too long.
     nt.connect(decoderAddress, -1, timeout_ms);
     if (nt.isConnected())
     {
         this.decoderAddress = nt.getHostPort();
         Debug.Log("Connected to " + this.decoderAddress);
         nt.modeChange("idle");
         if (connectedEvent != null)
         {
             connectedEvent.Invoke();
         }
     }
     else if (nt.getTimeStamp() > last_connected_time + lostConnectionTimeout_ms)
     {
         if (lostConnectionEvent != null)
         {
             lostConnectionEvent.Invoke();
         }
     }
 }