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 voidaddChannelFactory(java.lang.String channelName, ChannelFactory cf)voidallowGlobalRequest(java.lang.String requestName, GlobalRequestHandler handler)protected voidcloseChannel(Channel channel)booleancontainsChannelFactory(java.lang.String channelName)protected voidfreeChannel(Channel channel)protected int[]getAsyncMessageFilter()Implement this method by returning the message ids of the asyncrounous messages your implementation wants to receive.booleanisConnected()protected voidonGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData)protected voidonMessageReceived(SshMessage msg)Called by the service thread when an asyncronous message is received.protected voidonServiceAccept()Called when the service is accepted by the remote server.protected voidonServiceInit(int startMode)Called when the service is intialized.protected voidonServiceRequest()protected voidonStop()The service thread calls this method when the thread is exiting.booleanopenChannel(Channel channel)booleanopenChannel(Channel channel, ChannelEventListener eventListener)voidremoveChannelFactory(java.lang.String channelName)voidsendChannelData(Channel channel, byte[] data)voidsendChannelEOF(Channel channel)voidsendChannelExtData(Channel channel, int extendedType, byte[] data)protected voidsendChannelFailure(Channel channel)protected voidsendChannelOpenConfirmation(Channel channel)protected voidsendChannelOpenFailure(long remoteChannelId, long reasonCode, java.lang.String additionalInfo, java.lang.String languageTag)booleansendChannelRequest(Channel channel, java.lang.String requestType, boolean wantReply, byte[] requestData)voidsendChannelRequestFailure(Channel channel)voidsendChannelRequestSuccess(Channel channel)voidsendChannelWindowAdjust(Channel channel, long bytesToAdd)byte[]sendGlobalRequest(java.lang.String requestName, boolean wantReply, byte[] requestData)protected voidsendGlobalRequestFailure()protected voidsendGlobalRequestSuccess(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.IOExceptionSshException
-
onStop
protected void onStop()
Description copied from class:AsyncServiceThe service thread calls this method when the thread is exiting.
- Specified by:
onStopin 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.IOExceptionSshException
-
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.IOExceptionSshException
-
getAsyncMessageFilter
protected int[] getAsyncMessageFilter()
Description copied from class:AsyncServiceImplement this method by returning the message ids of the asyncrounous messages your implementation wants to receive.
- Specified by:
getAsyncMessageFilterin 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:AsyncServiceCalled by the service thread when an asyncronous message is received.
- Specified by:
onMessageReceivedin classAsyncService- Parameters:
msg-- Throws:
java.io.IOException
-
onServiceAccept
protected void onServiceAccept()
Description copied from class:ServiceCalled when the service is accepted by the remote server.
- Specified by:
onServiceAcceptin classService
-
onServiceInit
protected void onServiceInit(int startMode) throws java.io.IOExceptionDescription copied from class:ServiceCalled when the service is intialized.
- Specified by:
onServiceInitin classService- Parameters:
startMode-- Throws:
java.io.IOException
-
onServiceRequest
protected void onServiceRequest()
- Specified by:
onServiceRequestin 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-
-
-