- All Superinterfaces:
ChannelDecoder
,ChannelEncoder
An NetSwitch server has two types of devices: Connectors
and
Listeners
. A Connector (or client) connects to a remote
listener, and can have one (or more) bidirectional communication channels (or
sockets). A Listener (or server) waits for connections from remote
clients, and can have several bidirectional communication channels, one for
each client.
A ChannelCodec
is specified in the configuration file of the server,
and can be assigned to a Connector or a Listener. Each time a
device channel receives input bytes, it calls the ChannelCodec
to
decode the bytes and produce an inbound Message
. Also, each time a
channel writes a Message
, it calls the ChannelCodec
to encode
the message into an outbound sequence of bytes.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
initialize
(CodecContext context) Called to initialize the ChannelCodec.void
terminate
(CodecContext context) Called to terminate the ChannelCodec.Methods inherited from interface cl.netswitch.lib.channel.ChannelDecoder
decodeInbound
Methods inherited from interface cl.netswitch.lib.channel.ChannelEncoder
encodeOutbound
-
Method Details
-
initialize
Called to initialize the ChannelCodec.This method is called only once at the beginning of the life cycle of a channel. This method can be used to perform one-time initializations.
If this message throws and exception, the exception will be logged, and then processing will continue as if nothing had happened. In other worlds, the exception will be ignored.
- Parameters:
context
- the context of the codec.- Throws:
Exception
- if an error occurs.
-
terminate
Called to terminate the ChannelCodec.This method is called only once at the end of the life cycle of a channel. This method can be used to release resources, and perform other cleanup activities.
If this message throws and exception, the exception will be logged, and then processing will continue as if nothing had happened. In other worlds, the exception will be ignored.
- Parameters:
context
- the context of the codec.- Throws:
Exception
- if an error occurs.
-