this.peer = peer;
}
public void oneway(Object command) throws IOException {
if (disposed) {
throw new TransportDisposedIOException("Transport disposed.");
}
if (peer == null) {
throw new IOException("Peer not connected.");
}
TransportListener transportListener=null;
try {
// Disable the peer from changing his state while we try to enqueue onto him.
peer.enqueueValve.increment();
if (peer.disposed || peer.stopping.get()) {
throw new TransportDisposedIOException("Peer (" + peer.toString() + ") disposed.");
}
if (peer.started) {
if (peer.async) {
peer.getMessageQueue().put(command);
peer.wakeup();
} else {
transportListener = peer.transportListener;
}
enqueueValve.decrement();
} else {
peer.getMessageQueue().put(command);
}
} catch (InterruptedException e) {
throw IOExceptionSupport.create(e);
} finally {
// Allow the peer to change state again...
peer.enqueueValve.decrement();
}
if( transportListener!=null ) {
if( command == DISCONNECT ) {
transportListener.onException(new TransportDisposedIOException("Peer (" + peer.toString() + ") disposed."));
} else {
transportListener.onCommand(command);
}
}
}