示例#1
0
  private boolean connectSPPMon() {
    if (state == ConnectionEvent.CONNECTION_PENDING) {
      ExpCoordinator.print(
          new String("NCCPConnection(" + host + ", " + port + ").connect connection pending"), 0);
      while (state == ConnectionEvent.CONNECTION_PENDING) {
        try {
          Thread.sleep(500);
        } catch (java.lang.InterruptedException e) {
        }
      }
      return (isConnected());
    }

    state = ConnectionEvent.CONNECTION_PENDING;
    if (nonProxy != null) {
      try {
        nonProxy.connect();
      } catch (UnknownHostException e) {
        boolean rtn = informUserError("Don't know about host: " + host + ":" + e.getMessage());
        return rtn;
      } catch (SocketTimeoutException e) {
        boolean rtn = informUserError("Socket time out for " + host + ":" + e.getMessage());
        return rtn;
      } catch (IOException e) {
        boolean rtn = informUserError("Couldnt get I/O for " + host + ":" + e.getMessage());
        return rtn;
      }
    }
    return (isConnected());
  }
示例#2
0
 public void sendMessage(NCCP.Message msg) {
   if (isClosed() || isFailed()) connect();
   if (isConnected()) {
     ExpCoordinator.printer.print("NCCPConnection::sendMessage", 5);
     if (proxy != null) proxy.sendMessage(msg, this);
     else {
       if (nonProxy != null) nonProxy.sendMessage(msg);
     }
   } else // still can't connect
   {
     pendingMessages.add(msg);
   }
 }
示例#3
0
 public void close() {
   if (proxy != null && isConnected()) {
     proxy.closeConnection(this);
     setConnected(false);
   } else {
     if (nonProxy != null && isConnected()) {
       try {
         Thread.sleep(1000);
       } catch (java.lang.InterruptedException e2) {
       }
       nonProxy.close();
       setConnected(false);
     }
   }
 }
示例#4
0
 public void flush() {
   if (nonProxy != null) nonProxy.flush();
 }