|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.maverick.ssh.message.SshAbstractChannel
com.maverick.ssh2.Ssh2Channel
All terminal sessions, forwarded connections, etc are channels and this class implements the base SSH2 channel. Either side may open a channel and multiple channels are multiplexed into a single SSH connection. SSH2 channels are flow controlled, no data may be sent to a channel until a message is received to indicate that window space is available.
To open a channel, first create an instance of the channel as follows:
The second value passed into the contructor is the initial window space and also the maximum amount of window space that will be available to the other side. The channel manages the window space automatically by increasing the amount available once the data has been read from the channels InputStream and only when the current value falls below half of the maximum.Ssh2Channel channel = new Ssh2Channel("session", 32768, 32768);
After the channel has been created the channel is opened through a call to openChannel(Ssh2Channel channel). Once the channel is open you can use the IO streams to send and receive data.
Field Summary | |
static java.lang.String |
SESSION_CHANNEL
|
Fields inherited from class com.maverick.ssh.message.SshAbstractChannel |
CHANNEL_CLOSED, CHANNEL_OPEN, CHANNEL_UNINITIALIZED, channelid, manager, ms, state |
Constructor Summary | |
Ssh2Channel(java.lang.String name,
int windowsize,
int packetsize)
Construct an SSH2 channel |
Method Summary | |||
void |
addChannelEventListener(ChannelEventListener listener)
Provides an event listening mechanism. |
||
protected void |
channelEOF()
Called when the remote side data stream is EOF, by default this method does nothing |
||
protected void |
channelRequest(java.lang.String requesttype,
boolean wantreply,
byte[] requestdata)
Called when a channel request is received, by default this method sends a failure message if the remote side requests a reply. |
||
void |
close()
Closes the channel. |
||
protected byte[] |
create()
Called after the channel has been created by the |
protected com.maverick.ssh2.Ssh2Channel.ChannelInputStream |
createExtendedDataStream()
Currently reserved. |
boolean |
equals(java.lang.Object obj)
This channel is equal to another channel if the channel id's are equal. |
||
java.io.InputStream |
getInputStream()
Get an InputStream to read incoming channel data. |
||
protected com.maverick.ssh.message.SshMessageStore |
getMessageStore()
|
||
java.lang.String |
getName()
Get the name of the channel. |
||
java.io.OutputStream |
getOutputStream()
Get an OutputStream to write outgoing channel data. |
||
protected com.maverick.ssh.message.MessageObserver |
getStickyMessageIds()
|
||
protected void |
open(int remoteid,
int remotewindow,
int remotepacket)
Called once an SSH_MSG_CHANNEL_OPEN_CONFIRMATION has been sent. |
||
protected void |
open(int remoteid,
int remotewindow,
int remotepacket,
byte[] responsedata)
Once a SSH_MSG_CHANNEL_OPEN_CONFIRMATION message is received the framework calls this method to complete the channel open operation. |
||
protected boolean |
processChannelMessage(com.maverick.ssh.message.SshChannelMessage msg)
Processes channel request messages by passing the request through to channelRequest(). |
||
protected void |
processExtendedData(int typecode,
byte[] buf,
int offset,
int len)
Called when extended data arrives. |
||
protected void |
processStandardData(byte[] buf,
int offset,
int len)
Called when channel data arrives, by default this method makes the data available in the channels InputStream. |
||
boolean |
sendRequest(java.lang.String requesttype,
boolean wantreply,
byte[] requestdata)
Sends a channel request. |
||
void |
setAutoConsumeInput(boolean autoConsumeInput)
Automatically consume input data |
Methods inherited from class com.maverick.ssh.message.SshAbstractChannel |
getChannelId, init, isClosed |
Methods inherited from class java.lang.Object |
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final java.lang.String SESSION_CHANNEL
Constructor Detail |
public Ssh2Channel(java.lang.String name, int windowsize, int packetsize)
Construct an SSH2 channel
name
- the name of the channel, for example "session"windowsize
- the initial window sizepacketsize
- the maximum packet sizeMethod Detail |
protected com.maverick.ssh.message.MessageObserver getStickyMessageIds()
public void setAutoConsumeInput(boolean autoConsumeInput)
SshChannel
autoConsumeInput
- booleanprotected com.maverick.ssh.message.SshMessageStore getMessageStore() throws SshException
SshException
public java.lang.String getName()
public java.io.InputStream getInputStream()
SshIO
public java.io.OutputStream getOutputStream()
SshIO
public void addChannelEventListener(ChannelEventListener listener)
SshChannel
listener
- protected byte[] create()
protected void open(int remoteid, int remotewindow, int remotepacket) throws java.io.IOException
remoteid
- remotewindow
- remotepacket
-
java.io.IOException
protected void open(int remoteid, int remotewindow, int remotepacket, byte[] responsedata) throws java.io.IOException
remoteid
- the senders idremotewindow
- the initial window space available for sending dataremotepacket
- the maximum packet size available for sending dataresponsedata
- the data returned from the remote side in the SSH_MSG_CHANNEL_OPEN_CONFIRMATION message
java.io.IOException
protected boolean processChannelMessage(com.maverick.ssh.message.SshChannelMessage msg) throws SshException
SshException
protected void processStandardData(byte[] buf, int offset, int len) throws SshException
buf
- offset
- len
-
java.io.IOException
SshException
protected void processExtendedData(int typecode, byte[] buf, int offset, int len) throws SshException
com.maverick.ssh.ChannelEventListener#extendedDataReceived(com.maverick.ssh.Channel, byte[], int, int, int)
event so to maintain code compatibility always call the
super method in any overidden method.
typecode
- the type of extended databuf
- the data bufferoffset
- the offsetlen
- the length
java.io.IOException
SshException
protected com.maverick.ssh2.Ssh2Channel.ChannelInputStream createExtendedDataStream()
public boolean sendRequest(java.lang.String requesttype, boolean wantreply, byte[] requestdata) throws SshException
requesttype
- the name of the request, for example "pty-req"wantreply
- specifies whether the remote side should send a success/failure messagerequestdata
- the request data
true
if the request succeeded and wantreply=true, otherwise false
java.io.IOException
SshException
public void close()
public boolean equals(java.lang.Object obj)
protected void channelRequest(java.lang.String requesttype, boolean wantreply, byte[] requestdata) throws SshException
requesttype
- the name of the requestwantreply
- specifies whether the remote side requires a success/failure messagerequestdata
- the request data
java.io.IOException
SshException
protected void channelEOF()
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |