# Openfire Message Handling with Netty The following diagram shows how network messages (e.g. TLS, XMPP stanzas) are processed by the Netty-based networking layer in Openfire. ```mermaid sequenceDiagram title Message Handling autonumber NioEventLoop->>+NioSocketChannel: read() NioSocketChannel->>+DefaultChannelPipeline: fireChannelRead() Note over SslHandler: Handles TLS negotiation, added
to the pipeline dynamically
if TLS is deemed necessary DefaultChannelPipeline->>+SslHandler: ChannelInboundHandler.channelRead() SslHandler->>+SslHandler: decode() SslHandler->>+SslHandler: ChannelHandlerContext.fireChannelRead() Note over NettyXMPPDecoder: Decodes incoming ByteBuffers
into XMPP stanza strings SslHandler->>+NettyXMPPDecoder: channelRead() NettyXMPPDecoder->>+NettyXMPPDecoder: ByteToMessageDecoder.channelRead() NettyXMPPDecoder->>+NettyXMPPDecoder: decode() NettyXMPPDecoder->>+NettyXMPPDecoder: ChannelHandlerContext.fireChannelRead() NettyXMPPDecoder->>+NettyConnectionHandler: channelRead() Note over NettyConnectionHandler: Into business logic, create &
destroy sessions, process stanzas NettyConnectionHandler->>+NettyConnectionHandler: ctx.attr(HANDLER).get() NettyConnectionHandler->>+StanzaHandler: process(message) Note over StanzaHandler: Handles session creation
& common stanzas StanzaHandler->>+StanzaHandler: process(message) Note over ServerStanzaHandler: Handles stanzas specific to a
connection type e.g. S2S
dialback result stanzas StanzaHandler->>+ServerStanzaHandler: processUnknownPacket(message) Note over ServerStanzaHandler, StanzaHandler: Responses are sent via the NettyConnection
passed to StanzaHandler on instantiation
during bootstrap by NettyConnectionHandler StanzaHandler->>+NettyConnection: connection.deliverRawText("") Note over ChannelHandlerContext: Out into the Netty pipeline NettyConnection->>+ChannelHandlerContext: writeAndFlush("") ```