| Method from com.sshtools.j2ssh.connection.IOChannel Detail: |
public void bindInputStream(InputStream boundInputStream) throws IOException {
this.boundInputStream = boundInputStream;
this.ios = new IOStreamConnector();
if (state.getValue() == ChannelState.CHANNEL_OPEN) {
ios.setCloseInput(false);
ios.setCloseOutput(false);
ios.connect(boundInputStream, out);
}
}
|
public void bindOutputStream(OutputStream boundOutputStream) throws IOException {
// Synchronize on the incoming message store to ensure that no other
// messages are added whilst we transfer to a bound state
synchronized (incoming) {
this.boundOutputStream = boundOutputStream;
if (state.getValue() == ChannelState.CHANNEL_OPEN) {
sendOutstandingMessages();
}
}
}
|
public ChannelInputStream getInputStream() {
return in;
}
|
public ChannelOutputStream getOutputStream() {
return out;
}
|
protected void init(ConnectionProtocol connection,
long localChannelId,
long senderChannelId,
long initialWindowSize,
long maximumPacketSize) throws IOException {
this.in = new ChannelInputStream(incoming); //ChannelInputStream.createStandard(incoming);
this.out = new ChannelOutputStream(this);
super.init(connection, localChannelId, senderChannelId,
initialWindowSize, maximumPacketSize);
}
|
protected void onChannelClose() throws IOException {
// Close the input/output streams
if (!in.isClosed()) {
in.close();
}
if (!out.isClosed()) {
out.close();
}
// Close the bound channel
/* if(boundIOChannel!=null && !boundIOChannel.isClosed())
boundIOChannel.close();*/
// Close the IOStream connector if were bound
if (ios != null) {
ios.close();
}
}
|
protected void onChannelData(SshMsgChannelData msg) throws IOException {
// Synchronize on the message store to ensure that another thread
// does not try to read its data. This will make sure that the incoming
// messages are not being flushed to an outputstream after a bind
synchronized (incoming) {
if (boundOutputStream != null) {
try {
boundOutputStream.write(msg.getChannelData());
} catch (IOException ex) {
log.info(
"Could not route data to the bound OutputStream; Closing channel.");
log.info(ex.getMessage());
close();
}
} else {
incoming.addMessage(msg);
}
}
}
|
protected void onChannelEOF() throws IOException {
if (!in.isClosed()) {
in.close();
}
}
|
protected void onChannelExtData(SshMsgChannelExtendedData msg) throws IOException {
// This class will not deal with extended data
// incoming.addMessage(msg);
}
|
protected void open() throws IOException {
super.open();
// If were bound send any outstanding messages sitting around
if (boundOutputStream != null) {
sendOutstandingMessages();
}
// Start the bound inputstream
if ((boundInputStream != null) && (ios == null)) {
ios.setCloseInput(false);
ios.setCloseOutput(false);
ios.connect(boundInputStream, out);
}
}
|
public void setLocalEOF() throws IOException {
super.setLocalEOF();
if (!out.isClosed()) {
out.close();
}
}
|