public interface Channel extends SessionHolder<Session>, ChannelIdentifier, 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 |
EMPTY
NONE
Modifier and Type | Method and Description |
---|---|
void |
addRequestHandler(RequestHandler<Channel> handler) |
default void |
addRequestHandlers(Collection<? extends RequestHandler<Channel>> handlers) |
LocalWindow |
getLocalWindow() |
long |
getRecipient() |
RemoteWindow |
getRemoteWindow() |
List<RequestHandler<Channel>> |
getRequestHandlers() |
void |
handleChannelRegistrationResult(ConnectionService service,
Session session,
long 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(long 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,
long id)
Invoked when the local channel is initial created
|
boolean |
isEofSignalled() |
boolean |
isInitialized() |
OpenFuture |
open(long 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)
Attempts to resolve the associated value by going up the store's hierarchy (if any)
|
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, getSessionContext
getChannelId
addChannelListener, getChannelListenerProxy, removeChannelListener
getBoolean, getBooleanProperty, getCharset, getInteger, getIntProperty, getLong, getLongProperty, getObject, getParentPropertyResolver, getProperties, getString, getStringProperty, isEmpty, isEmpty
clearAttributes, computeAttributeIfAbsent, removeAttribute, setAttribute
attributeKeys, getAttribute, getAttributesCount, ofAttributesMap, ofKeyValuePair
getChannelStreamWriterResolver, resolveChannelStreamWriter, resolveChannelStreamWriterResolver, setChannelStreamWriterResolver
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
static final String CHANNEL_EXEC
static final String CHANNEL_SHELL
static final String CHANNEL_SUBSYSTEM
long getRecipient()
LocalWindow getLocalWindow()
RemoteWindow 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, long id) throws IOException
service
- The ConnectionService
through which the channel is initializedsession
- The Session
associated with the channelid
- The locally assigned channel identifier (UINT32 represented as a long
)IOException
- If failed to process the initializationvoid handleChannelRegistrationResult(ConnectionService service, Session session, long 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 identifier (UINT32 represented as a long
)registered
- 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, long)
was successfully completedboolean isEofSignalled()
true
if the peer signaled that it will not send any more dataOpenFuture open(long recipient, long rwSize, long packetSize, Buffer buffer)
recipient
- Recipient identifier (UINT32 represented as a long
)rwSize
- 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(long recipient, long rwSize, long packetSize, Buffer buffer) throws IOException
recipient
- Recipient identifier (UINT32 represented as a long
)rwSize
- 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)
AttributeRepository
resolveAttribute
in interface AttributeRepository
T
- The generic attribute typekey
- The key of the attribute; must not be null
.null
if there is no value associated with the specified key either in this repository or any
of its ancestors (if any available)static <T> T resolveAttribute(Channel channel, AttributeRepository.AttributeKey<T> key)
T
- The generic attribute typechannel
- The Channel
- ignored if null
key
- The attribute key - never null
null
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–2024 The Apache Software Foundation. All rights reserved.