Beispiel #1
0
 public void write(ONL.Writer wrtr) throws java.io.IOException {
   wrtr.writeString(host);
   wrtr.writeInt(port);
   short cid = 0;
   if (proxy != null) cid = proxy.getConnectionID(this);
   wrtr.writeShort(cid);
 }
Beispiel #2
0
 public boolean connect() {
   ExpCoordinator.printer.print("NCCPConnection.connect", 3);
   if (host.length() == 0) {
     ExpCoordinator.printer.print("NCCPConnection.connect host is not set", 6);
     return false;
   }
   if (proxy == null && nonProxy == null) {
     ExpCoordinator.printer.print("NCCPConnection.connect proxy null");
     return false;
   }
   if (ExpCoordinator.isSPPMon()) return (connectSPPMon());
   if (state == ConnectionEvent.CONNECTION_CLOSED || state == ConnectionEvent.CONNECTION_FAILED) {
     state = ConnectionEvent.CONNECTION_PENDING;
     if (proxy != null) {
       proxy.openConnection(this);
     }
   }
   /*
   if (nonProxy != null && proxy == null)
   {
   	return (nonProxy.connect());
   }
   */
   return true;
 }
Beispiel #3
0
 public void read(ONL.Reader rdr) throws java.io.IOException {
   setHost(new String(rdr.readString()));
   setPort(rdr.readInt());
   short cid = (short) rdr.readShort();
   ExpCoordinator.print(
       new String("NCCPConnection.read host:" + getHost() + " port:" + getPort() + " cid:" + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
Beispiel #4
0
 public void setConnectionID(short cid) {
   ExpCoordinator.print(
       new String(
           "NCCPConnection.setConnectionID host:"
               + getHost()
               + " port:"
               + getPort()
               + " cid:"
               + cid),
       5);
   if (proxy != null) proxy.setConnectionID(this, cid);
 }
Beispiel #5
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);
   }
 }
Beispiel #6
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);
     }
   }
 }
Beispiel #7
0
 public short getConnectionID() {
   if (proxy != null) return ((short) proxy.getConnectionID(this));
   else return ((short) 0);
 }
Beispiel #8
0
 public void setProxy(Proxy p) {
   proxy = p;
   proxy.addConnection(this);
 }