예제 #1
0
  public void receivedAck(final FileRequest fr, final AESObject aes) {
    // so the other user has the file and will send it to us through the
    // socket (or is already transmitting).
    if (!this.currentRequest.equals(fr)) {
      log.warn("received a ack, but not for the right file request");
      return;
    }
    try {
      log.info("received server ACK, starting file transfer");
      AvailableLater<IcePeer> peerAvl = iceconnect.getNomination(fr.getPeer());
      final INegotiationSuccessListener listener = getCurrentListener();
      new AvailableLaterWrapperObject<Void, IcePeer>(peerAvl) {

        @Override
        public Void calculate() throws Exception {
          log.debug("we finally have a peer -- connecting");
          socket = udtconnect.connect(iceconnect.getSocket(), getSourceResult(), false);
          log.debug("connected -- running file transfer now");
          IceUdtFileTransfer ft = new IceUdtFileTransfer(fr, socket, aes);
          listener.succeeded(ft);
          ft.run();
          return null;
        }
      }.start();
    } catch (Exception e) {
      log.warn("received a Ack, but we couldn't find a socket", e);
      getCurrentListener()
          .failed(new IOException("No socket connection available. Try again later."));
    }
  }
예제 #2
0
 @Override
 public void run() {
   if (PROACTIVE) {
     iceconnect.getNomination(peerUserId);
   }
   while (running) {
     try {
       this.currentRequest = requests.poll(1, TimeUnit.SECONDS);
       if (this.currentRequest == null) continue;
       log.debug("handling request " + currentRequest);
       iceconnect.getNomination(peerUserId);
       handleRequest();
     } catch (InterruptedException e) {
       // might have been stopped, otherwise loop will continue
     }
   }
 }