ChannelHandler

cc.otavia.core.channel.ChannelHandler

Handles an I/O event or intercepts an I/O operation, and forwards it to its next handler in its ChannelPipeline. ===The context object=== A ChannelHandler is provided with a ChannelHandlerContext object. A ChannelHandler is supposed to interact with the ChannelPipeline it belongs to via a context object. Using the context object, the ChannelHandler can pass events upstream or downstream, modify the pipeline dynamically, or store the information (using AttributeKeys) which is specific to the handler. ===State management=== A ChannelHandler often needs to store some stateful information. The simplest and recommended approach is to use member variables:

  trait Msg {
     // your methods here
  }

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Value members

Concrete methods

def bind(ctx: ChannelHandlerContext, local: SocketAddress, future: ChannelFuture): ChannelFuture

Called once a bind operation is made.

Called once a bind operation is made.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

local

the SocketAddress to which it should bound

Attributes

The Channel of the ChannelHandlerContext is now active

The Channel of the ChannelHandlerContext is now active

Attributes

def channelExceptionCaught(ctx: ChannelHandlerContext, cause: Throwable): Unit

Gets called if a Throwable was thrown when handling inbound events.

Gets called if a Throwable was thrown when handling inbound events.

Attributes

def channelExceptionCaught(ctx: ChannelHandlerContext, cause: Throwable, id: Long): Unit

Gets called if a Throwable was thrown when handling inbound events.

Gets called if a Throwable was thrown when handling inbound events.

Attributes

The Channel of the ChannelHandlerContext was registered is now inactive and reached its end of lifetime.

The Channel of the ChannelHandlerContext was registered is now inactive and reached its end of lifetime.

Attributes

def channelInboundEvent(ctx: ChannelHandlerContext, evt: AnyRef): Unit

Gets called if a custom inbound event happened.

Gets called if a custom inbound event happened.

Attributes

def channelRead(ctx: ChannelHandlerContext, msg: AnyRef): Unit

Invoked when the current Channel has read a message from the peer.

Invoked when the current Channel has read a message from the peer.

Attributes

def channelRead(ctx: ChannelHandlerContext, msg: AnyRef, msgId: Long): Unit

Invoked when the current Channel has read a message from the peer.

Invoked when the current Channel has read a message from the peer.

Attributes

Invoked when the last message read by the current read operation has been consumed by channelRead. If ChannelOption.AUTO_READ is off, no further attempt to read an inbound data from the current Channel will be made until ChannelOutboundInvoker.read is called.

Invoked when the last message read by the current read operation has been consumed by channelRead. If ChannelOption.AUTO_READ is off, no further attempt to read an inbound data from the current Channel will be made until ChannelOutboundInvoker.read is called.

Attributes

The Channel of the ChannelHandlerContext was shutdown in one direction. This might either be because the remote peer did cause a shutdown of one direction or the shutdown was requested explicit by us and was executed.

The Channel of the ChannelHandlerContext was shutdown in one direction. This might either be because the remote peer did cause a shutdown of one direction or the shutdown was requested explicit by us and was executed.

Value parameters

ctx

the ChannelHandlerContext for which we notify about the completed shutdown.

direction

the ChannelShutdownDirection of the completed shutdown.

Attributes

def channelTimeoutEvent(ctx: ChannelHandlerContext, id: Long): Unit

Gets called if a channel timeout event happened.

Gets called if a channel timeout event happened.

Value parameters

ctx

ChannelHandlerContext of this handler.

id

registered cc.otavia.core.timer.TimeoutTrigger id of this timeout event.

Attributes

Attributes

Gets called once the writable state of a Channel changed. You can check the state with Channel.writableBytes or Channel.isWritable .

Gets called once the writable state of a Channel changed. You can check the state with Channel.writableBytes or Channel.isWritable .

Attributes

Called once a close operation is made.

Called once a close operation is made.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

Attributes

def connect(ctx: ChannelHandlerContext, remote: SocketAddress, local: Option[SocketAddress], future: ChannelFuture): ChannelFuture

Called once a connect operation is made.

Called once a connect operation is made.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

local

the option SocketAddress which is used as source on connect

remote

the SocketAddress to which it should connect

Attributes

Called once a deregister operation is made from the current registered cc.otavia.core.actor.ChannelsActor

Called once a deregister operation is made from the current registered cc.otavia.core.actor.ChannelsActor

Attributes

Called once a disconnect operation is made.

Called once a disconnect operation is made.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

Attributes

def flush(ctx: ChannelHandlerContext): Unit

Called once a flush operation is made. The flush operation will try to flush out all previous written messages that are pending.

Called once a flush operation is made. The flush operation will try to flush out all previous written messages that are pending.

Attributes

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Gets called after the ChannelHandler was added to the actual context and it's ready to handle events.

Attributes

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

Gets called after the ChannelHandler was removed from the actual context and it doesn't handle events anymore.

Attributes

def hasInboundAdaptive: Boolean

If the handler has inbound AdaptiveBuffer

If the handler has inbound AdaptiveBuffer

Attributes

def hasOutboundAdaptive: Boolean

If the handler has outbound AdaptiveBuffer

If the handler has outbound AdaptiveBuffer

Attributes

def isBufferHandler: Boolean
def isSharable: Boolean

Attributes

Returns

true if this handler is sharable and thus can be added to more than one ChannelPipeline. By default, this method returns false. If this method returns false, you have to create a new handler instance every time you add it to a pipeline because it has unshared state such as member variables.

def open(ctx: ChannelHandlerContext, path: Path, options: Seq[OpenOption], attrs: Seq[FileAttribute[_]], future: ChannelFuture): ChannelFuture

Called once a open operation is made.

Called once a open operation is made.

Value parameters

attrs

An optional list of file attributes to set atomically when creating the file

ctx

the ChannelHandlerContext for which the bind operation is made

options

Options specifying how the file is opened

path

The path of the file to open or create

Attributes

The number of the outbound bytes that are buffered / queued in this ChannelHandler. This number will affect the writability of the Channel together the buffered / queued bytes in the Channel itself. By default this methods returns 0. If the ChannelHandler implementation buffers / queues outbound data this methods should be implemented to return the correct value.

The number of the outbound bytes that are buffered / queued in this ChannelHandler. This number will affect the writability of the Channel together the buffered / queued bytes in the Channel itself. By default this methods returns 0. If the ChannelHandler implementation buffers / queues outbound data this methods should be implemented to return the correct value.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

Attributes

Returns

the number of buffered / queued bytes.

def read(ctx: ChannelHandlerContext, readPlan: ReadPlan): Unit

Called once a read operation is made from the current registered cc.otavia.core.actor.ChannelsActor. If the ChannelHandler implementation queues the read and another read happens it is free to drop the first ReadPlan and just use the last one.

Called once a read operation is made from the current registered cc.otavia.core.actor.ChannelsActor. If the ChannelHandler implementation queues the read and another read happens it is free to drop the first ReadPlan and just use the last one.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

readPlan

The ReadPlan that should be used to allocate a Buffer if needed (for reading the data).

Attributes

Called once a register operation is made to register for IO on the cc.otavia.core.actor.ChannelsActor.

Called once a register operation is made to register for IO on the cc.otavia.core.actor.ChannelsActor.

Attributes

def sendOutboundEvent(ctx: ChannelHandlerContext, event: AnyRef): Unit

Called once a custom defined outbound event was sent. This operation will pass the event through the ChannelPipeline in the outbound direction.

Called once a custom defined outbound event was sent. This operation will pass the event through the ChannelPipeline in the outbound direction.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

event

the event.

Attributes

Called once a shutdown operation was requested and should be executed.

Called once a shutdown operation was requested and should be executed.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

direction

the ChannelShutdownDirection that is used.

Attributes

def write(ctx: ChannelHandlerContext, msg: AnyRef): Unit

Called once a write operation is made. The write operation will write the messages through the ChannelPipeline. Those are then ready to be flushed to the actual Channel once Channel.flush is called.

Called once a write operation is made. The write operation will write the messages through the ChannelPipeline. Those are then ready to be flushed to the actual Channel once Channel.flush is called.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

msg

the message to write

Attributes

def write(ctx: ChannelHandlerContext, msg: AnyRef, msgId: Long): Unit

Called once a write operation is made. The write operation will write the messages through the ChannelPipeline. Those are then ready to be flushed to the actual Channel once Channel.flush is called.

Called once a write operation is made. The write operation will write the messages through the ChannelPipeline. Those are then ready to be flushed to the actual Channel once Channel.flush is called.

Value parameters

ctx

the ChannelHandlerContext for which the bind operation is made

msg

the message to write

msgId

the id of the message

Attributes