Class ServerInitializer
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
server.netty.ServerInitializer
- All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
public class ServerInitializer
extends io.netty.channel.ChannelInitializer<io.netty.channel.socket.SocketChannel>
Netty
ChannelInitializer,為每個新的 TCP 連線組裝封包處理 pipeline。
當客戶端完成 TCP 握手後,initChannel(SocketChannel) 依序向 pipeline 加入:
IdleStateHandler(25 秒讀寫逾時,偵測殭屍連線)。MaplePacketDecoder(入站:解密並還原封包位元組陣列)。MaplePacketEncoder(出站:加密並寫入網路緩衝區)。MapleServerHandler(業務邏輯:opcode 分派、MapleClient管理)。
由 ServerConnection 在 ServerBootstrap.childHandler 中使用;
ServerType 與頻道資訊在建構時注入,並透傳給 MapleServerHandler
以區分登入/頻道/商城伺服器的處理邏輯。
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidinitChannel(io.netty.channel.socket.SocketChannel channel) Methods inherited from class io.netty.channel.ChannelInitializer
channelRegistered, exceptionCaught, handlerAdded, handlerRemovedMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelActive, channelInactive, channelRead, channelReadComplete, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, isSharable
-
Constructor Details
-
ServerInitializer
-
-
Method Details
-
initChannel
-