ChannelInitializer

cc.otavia.core.channel.ChannelInitializer
abstract class ChannelInitializer[C <: Channel] extends ChannelHandler

A special ChannelHandler which offers an easy way to initialize a Channel once it was registered to its ChannelsActor. Implementations are most often used in the context of ChannelsActor.handler, to setup the ChannelPipeline of a Channel.

    class MyChannelInitializer extends ChannelInitializer[Channel] {
        override protected def initChannel(ch: Channel): Unit = {
            ch.pipeline.addLast("myHandler", new MyHandler())
        }
    }

Be aware that this class is marked as isSharable and so the implementation must be safe to be re-used

Type parameters

C

A sub-type of Channel

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Abstract methods

protected def initChannel(ch: C): Unit

This method will be called once the Channel was registered. After the method returns this instance will be removed from the ChannelPipeline of the Channel.

This method will be called once the Channel was registered. After the method returns this instance will be removed from the ChannelPipeline of the Channel.

Value parameters

ch

the Channel which was registered.

Attributes

Throws
Exception

is thrown if an error occurs. In that case it will be handled by channelExceptionCaught which will by default close the Channel.

Concrete methods

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

Handle the Throwable by logging and closing the Channel. Sub-classes may override this.

Handle the Throwable by logging and closing the Channel. Sub-classes may override this.

Attributes

Definition Classes
override def handlerAdded(ctx: ChannelHandlerContext): Unit

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

Definition Classes
override 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.

Definition Classes

Inherited 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

Inherited from:
ChannelHandler

The Channel of the ChannelHandlerContext is now active

The Channel of the ChannelHandlerContext is now active

Attributes

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler
def channelInboundEvent(ctx: ChannelHandlerContext, evt: AnyRef): Unit

Gets called if a custom inbound event happened.

Gets called if a custom inbound event happened.

Attributes

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler

Attributes

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

Attributes

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler
def hasInboundAdaptive: Boolean

If the handler has inbound AdaptiveBuffer

If the handler has inbound AdaptiveBuffer

Attributes

Inherited from:
ChannelHandler
def hasOutboundAdaptive: Boolean

If the handler has outbound AdaptiveBuffer

If the handler has outbound AdaptiveBuffer

Attributes

Inherited from:
ChannelHandler
def isBufferHandler: Boolean

Attributes

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

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.

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler

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

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler
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

Inherited from:
ChannelHandler