public interface Channel extends SessionHolder<Session>, ChannelListenerManager, PropertyResolver, AttributeStore, ChannelStreamWriterResolverManager, Closeable
AttributeRepository.AttributeKey<T>| Modifier and Type | Field and Description |
|---|---|
static String |
CHANNEL_EXEC |
static String |
CHANNEL_SHELL |
static String |
CHANNEL_SUBSYSTEM |
EMPTYNONE| Modifier and Type | Method and Description |
|---|---|
void |
addRequestHandler(RequestHandler<Channel> handler) |
default void |
addRequestHandlers(Collection<? extends RequestHandler<Channel>> handlers) |
int |
getId() |
Window |
getLocalWindow() |
int |
getRecipient() |
Window |
getRemoteWindow() |
List<RequestHandler<Channel>> |
getRequestHandlers() |
void |
handleChannelRegistrationResult(ConnectionService service,
Session session,
int id,
boolean registered)
Invoked after being successfully registered by the connection service - should throw a
RuntimeException
if not registered |
void |
handleChannelUnregistration(ConnectionService service)
Called by the connection service to inform the channel that it has bee unregistered.
|
void |
handleClose()
Invoked when
SSH_MSG_CHANNEL_CLOSE received |
void |
handleData(Buffer buffer)
Invoked when
SSH_MSG_CHANNEL_DATA received |
void |
handleEof()
Invoked when
SSH_MSG_CHANNEL_EOF received |
void |
handleExtendedData(Buffer buffer)
Invoked when
SSH_MSG_CHANNEL_EXTENDED_DATA received |
void |
handleFailure()
Invoked when
SSH_MSG_CHANNEL_FAILURE received |
void |
handleOpenFailure(Buffer buffer)
For a client channel, this method will be called internally by the session when the server has rejected this
channel opening.
|
void |
handleOpenSuccess(int recipient,
long rwSize,
long packetSize,
Buffer buffer)
For a client channel, this method will be called internally by the session when the confirmation has been
received.
|
void |
handleRequest(Buffer buffer)
Invoked when
SSH_MSG_CHANNEL_REQUEST received |
void |
handleSuccess()
Invoked when
SSH_MSG_CHANNEL_SUCCESS received |
void |
handleWindowAdjust(Buffer buffer)
Invoked when
SSH_MSG_CHANNEL_WINDOW_ADJUST received |
void |
init(ConnectionService service,
Session session,
int id)
Invoked when the local channel is initial created
|
boolean |
isEofSignalled() |
boolean |
isInitialized() |
OpenFuture |
open(int recipient,
long rwSize,
long packetSize,
Buffer buffer)
For a server channel, this method will actually open the channel
|
void |
removeRequestHandler(RequestHandler<Channel> handler) |
default void |
removeRequestHandlers(Collection<? extends RequestHandler<Channel>> handlers) |
default <T> T |
resolveAttribute(AttributeRepository.AttributeKey<T> key) |
static <T> T |
resolveAttribute(Channel channel,
AttributeRepository.AttributeKey<T> key)
Attempts to use the channel attribute, if not found then tries the session
|
IoWriteFuture |
writePacket(Buffer buffer)
Encode and send the given buffer.
|
getSession, getSessionContextaddChannelListener, getChannelListenerProxy, removeChannelListenergetBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmptyclearAttributes, computeAttributeIfAbsent, removeAttribute, setAttributeattributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePairgetChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolveraddCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListenerstatic final String CHANNEL_EXEC
static final String CHANNEL_SHELL
static final String CHANNEL_SUBSYSTEM
int getId()
int getRecipient()
Window getLocalWindow()
Window getRemoteWindow()
List<RequestHandler<Channel>> getRequestHandlers()
void addRequestHandler(RequestHandler<Channel> handler)
default void addRequestHandlers(Collection<? extends RequestHandler<Channel>> handlers)
void removeRequestHandler(RequestHandler<Channel> handler)
default void removeRequestHandlers(Collection<? extends RequestHandler<Channel>> handlers)
void handleClose()
throws IOException
SSH_MSG_CHANNEL_CLOSE receivedIOException - If failed to handle the messagevoid handleWindowAdjust(Buffer buffer) throws IOException
SSH_MSG_CHANNEL_WINDOW_ADJUST receivedbuffer - The rest of the message data Buffer after decoding the channel identifiersIOException - If failed to handle the messagevoid handleRequest(Buffer buffer) throws IOException
SSH_MSG_CHANNEL_REQUEST receivedbuffer - The rest of the message data Buffer after decoding the channel identifiersIOException - If failed to handle the messagevoid handleData(Buffer buffer) throws IOException
SSH_MSG_CHANNEL_DATA receivedbuffer - The rest of the message data Buffer after decoding the channel identifiersIOException - If failed to handle the messagevoid handleExtendedData(Buffer buffer) throws IOException
SSH_MSG_CHANNEL_EXTENDED_DATA receivedbuffer - The rest of the message data Buffer after decoding the channel identifiersIOException - If failed to handle the messagevoid handleEof()
throws IOException
SSH_MSG_CHANNEL_EOF receivedIOException - If failed to handle the messagevoid handleSuccess()
throws IOException
SSH_MSG_CHANNEL_SUCCESS receivedIOException - If failed to handle the messagevoid handleFailure()
throws IOException
SSH_MSG_CHANNEL_FAILURE receivedIOException - If failed to handle the messagevoid init(ConnectionService service, Session session, int id) throws IOException
service - The ConnectionService through which the channel is initializedsession - The Session associated with the channelid - The locally assigned channel identifierIOException - If failed to process the initializationvoid handleChannelRegistrationResult(ConnectionService service, Session session, int id, boolean registered)
RuntimeException
if not registeredservice - The ConnectionService through which the channel is registeredsession - The Session associated with the channelid - The locally assigned channel identifierregistered - Whether registration was successful or notvoid handleChannelUnregistration(ConnectionService service)
service - The ConnectionService through which the channel is unregisteredboolean isInitialized()
true if call to init(ConnectionService, Session, int) was successfully completedboolean isEofSignalled()
true if the peer signaled that it will not send any more dataOpenFuture open(int recipient, long rwSize, long packetSize, Buffer buffer)
recipient - Recipient identifierrwSize - Read/Write window size (uint32)packetSize - Preferred maximum packet size (uint32)buffer - Incoming Buffer that triggered the call. Note: the buffer's read position is
exactly after the information that read to this call was decodedOpenFuture for the channel open requestvoid handleOpenSuccess(int recipient,
long rwSize,
long packetSize,
Buffer buffer)
throws IOException
recipient - Recipient identifierrwSize - Read/Write window size (uint32)packetSize - Preferred maximum packet size (uint32)buffer - Incoming Buffer that triggered the call. Note: the buffer's read position is
exactly after the information that read to this call was decodedIOException - If failed to handle the successvoid handleOpenFailure(Buffer buffer) throws IOException
buffer - Incoming Buffer that triggered the call. Note: the buffer's read position is
exactly after the information that read to this call was decodedIOException - If failed to handle the successdefault <T> T resolveAttribute(AttributeRepository.AttributeKey<T> key)
resolveAttribute in interface AttributeRepositorystatic <T> T resolveAttribute(Channel channel, AttributeRepository.AttributeKey<T> key)
T - The generic attribute typechannel - The Channel - ignored if nullkey - The attribute key - never nullnull if not foundSessionHolder.getSession(),
Session.resolveAttribute(Session, AttributeRepository.AttributeKey)IoWriteFuture writePacket(Buffer buffer) throws IOException
buffer - the buffer to encode and send. NOTE: the buffer must not be touched until the returned
write future is completed.IoWriteFuture that can be used to check when the packet has actually been sentIOException - if an error occurred when encoding or sending the packetCopyright © 2008–2021 The Apache Software Foundation. All rights reserved.