Package com.sshtools.j2ssh.connection
Class ConnectionProtocol
- java.lang.Object
-
- com.sshtools.j2ssh.transport.Service
-
- com.sshtools.j2ssh.transport.AsyncService
-
- com.sshtools.j2ssh.connection.ConnectionProtocol
-
- All Implemented Interfaces:
java.lang.Runnable
public class ConnectionProtocol extends AsyncService
- Version:
- $Revision: 1.68 $
- Author:
- $author$
-
-
Field Summary
-
Fields inherited from class com.sshtools.j2ssh.transport.AsyncService
thread
-
Fields inherited from class com.sshtools.j2ssh.transport.Service
ACCEPTING_SERVICE, messageStore, REQUESTING_SERVICE, startMode, state, transport
-
-
Constructor Summary
Constructors Constructor Description ConnectionProtocol()
Creates a new ConnectionProtocol object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addChannelFactory(java.lang.String channelName, ChannelFactory cf)
void
allowGlobalRequest(java.lang.String requestName, GlobalRequestHandler handler)
protected void
closeChannel(Channel channel)
boolean
containsChannelFactory(java.lang.String channelName)
protected void
freeChannel(Channel channel)
protected int[]
getAsyncMessageFilter()
Implement this method by returning the message ids of the asyncrounous messages your implementation wants to receive.boolean
isConnected()
protected void
onGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData)
protected void
onMessageReceived(SshMessage msg)
Called by the service thread when an asyncronous message is received.protected void
onServiceAccept()
Called when the service is accepted by the remote server.protected void
onServiceInit(int startMode)
Called when the service is intialized.protected void
onServiceRequest()
protected void
onStop()
The service thread calls this method when the thread is exiting.boolean
openChannel(Channel channel)
boolean
openChannel(Channel channel, ChannelEventListener eventListener)
void
removeChannelFactory(java.lang.String channelName)
void
sendChannelData(Channel channel, byte[] data)
void
sendChannelEOF(Channel channel)
void
sendChannelExtData(Channel channel, int extendedType, byte[] data)
protected void
sendChannelFailure(Channel channel)
protected void
sendChannelOpenConfirmation(Channel channel)
protected void
sendChannelOpenFailure(long remoteChannelId, long reasonCode, java.lang.String additionalInfo, java.lang.String languageTag)
boolean
sendChannelRequest(Channel channel, java.lang.String requestType, boolean wantReply, byte[] requestData)
void
sendChannelRequestFailure(Channel channel)
void
sendChannelRequestSuccess(Channel channel)
void
sendChannelWindowAdjust(Channel channel, long bytesToAdd)
byte[]
sendGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData)
protected void
sendGlobalRequestFailure()
protected void
sendGlobalRequestSuccess(byte[] requestData)
-
Methods inherited from class com.sshtools.j2ssh.transport.AsyncService
onStart, run
-
Methods inherited from class com.sshtools.j2ssh.transport.Service
getServiceName, getState, init, sendServiceAccept, start, stop
-
-
-
-
Method Detail
-
addChannelFactory
public void addChannelFactory(java.lang.String channelName, ChannelFactory cf) throws java.io.IOException
- Parameters:
channelName
-cf
-- Throws:
java.io.IOException
-
removeChannelFactory
public void removeChannelFactory(java.lang.String channelName)
- Parameters:
channelName
-
-
containsChannelFactory
public boolean containsChannelFactory(java.lang.String channelName)
- Parameters:
channelName
-- Returns:
-
allowGlobalRequest
public void allowGlobalRequest(java.lang.String requestName, GlobalRequestHandler handler)
- Parameters:
requestName
-handler
-
-
openChannel
public boolean openChannel(Channel channel) throws java.io.IOException
- Parameters:
channel
-- Returns:
- Throws:
java.io.IOException
-
isConnected
public boolean isConnected()
- Returns:
-
openChannel
public boolean openChannel(Channel channel, ChannelEventListener eventListener) throws java.io.IOException
- Parameters:
channel
-eventListener
-- Returns:
- Throws:
java.io.IOException
SshException
-
onStop
protected void onStop()
Description copied from class:AsyncService
The service thread calls this method when the thread is exiting.
- Specified by:
onStop
in classAsyncService
-
sendChannelData
public void sendChannelData(Channel channel, byte[] data) throws java.io.IOException
- Parameters:
channel
-data
-- Throws:
java.io.IOException
-
sendChannelEOF
public void sendChannelEOF(Channel channel) throws java.io.IOException
- Parameters:
channel
-- Throws:
java.io.IOException
-
sendChannelExtData
public void sendChannelExtData(Channel channel, int extendedType, byte[] data) throws java.io.IOException
- Parameters:
channel
-extendedType
-data
-- Throws:
java.io.IOException
-
sendChannelRequest
public boolean sendChannelRequest(Channel channel, java.lang.String requestType, boolean wantReply, byte[] requestData) throws java.io.IOException
- Parameters:
channel
-requestType
-wantReply
-requestData
-- Returns:
- Throws:
java.io.IOException
SshException
-
sendChannelRequestFailure
public void sendChannelRequestFailure(Channel channel) throws java.io.IOException
- Parameters:
channel
-- Throws:
java.io.IOException
-
sendChannelRequestSuccess
public void sendChannelRequestSuccess(Channel channel) throws java.io.IOException
- Parameters:
channel
-- Throws:
java.io.IOException
-
sendChannelWindowAdjust
public void sendChannelWindowAdjust(Channel channel, long bytesToAdd) throws java.io.IOException
- Parameters:
channel
-bytesToAdd
-- Throws:
java.io.IOException
-
sendGlobalRequest
public byte[] sendGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData) throws java.io.IOException
- Parameters:
requestName
-wantReply
-requestData
-- Returns:
- Throws:
java.io.IOException
SshException
-
getAsyncMessageFilter
protected int[] getAsyncMessageFilter()
Description copied from class:AsyncService
Implement this method by returning the message ids of the asyncrounous messages your implementation wants to receive.
- Specified by:
getAsyncMessageFilter
in classAsyncService
- Returns:
-
closeChannel
protected void closeChannel(Channel channel) throws java.io.IOException
- Parameters:
channel
-- Throws:
java.io.IOException
-
onGlobalRequest
protected void onGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData) throws java.io.IOException
- Parameters:
requestName
-wantReply
-requestData
-- Throws:
java.io.IOException
-
onMessageReceived
protected void onMessageReceived(SshMessage msg) throws java.io.IOException
Description copied from class:AsyncService
Called by the service thread when an asyncronous message is received.
- Specified by:
onMessageReceived
in classAsyncService
- Parameters:
msg
-- Throws:
java.io.IOException
-
onServiceAccept
protected void onServiceAccept()
Description copied from class:Service
Called when the service is accepted by the remote server.
- Specified by:
onServiceAccept
in classService
-
onServiceInit
protected void onServiceInit(int startMode) throws java.io.IOException
Description copied from class:Service
Called when the service is intialized.
- Specified by:
onServiceInit
in classService
- Parameters:
startMode
-- Throws:
java.io.IOException
-
onServiceRequest
protected void onServiceRequest()
- Specified by:
onServiceRequest
in classService
-
sendChannelFailure
protected void sendChannelFailure(Channel channel) throws java.io.IOException
- Parameters:
channel
-- Throws:
java.io.IOException
-
sendChannelOpenConfirmation
protected void sendChannelOpenConfirmation(Channel channel) throws java.io.IOException
- Parameters:
channel
-- Throws:
java.io.IOException
-
sendChannelOpenFailure
protected void sendChannelOpenFailure(long remoteChannelId, long reasonCode, java.lang.String additionalInfo, java.lang.String languageTag) throws java.io.IOException
- Parameters:
remoteChannelId
-reasonCode
-additionalInfo
-languageTag
-- Throws:
java.io.IOException
-
sendGlobalRequestFailure
protected void sendGlobalRequestFailure() throws java.io.IOException
- Throws:
java.io.IOException
-
sendGlobalRequestSuccess
protected void sendGlobalRequestSuccess(byte[] requestData) throws java.io.IOException
- Parameters:
requestData
-- Throws:
java.io.IOException
-
freeChannel
protected void freeChannel(Channel channel)
- Parameters:
channel
-
-
-