public class NetworkManager
extends io.netty.channel.SimpleChannelInboundHandler
Modifier and Type | Field and Description |
---|---|
static io.netty.util.AttributeKey |
attrKeyConnectionState |
static io.netty.util.AttributeKey |
attrKeyReceivable |
static io.netty.util.AttributeKey |
attrKeySendable |
static io.netty.channel.nio.NioEventLoopGroup |
eventLoops |
static org.apache.logging.log4j.Marker |
logMarkerNetwork |
static org.apache.logging.log4j.Marker |
logMarkerPackets |
Constructor and Description |
---|
NetworkManager(boolean p_i45147_1_) |
Modifier and Type | Method and Description |
---|---|
io.netty.channel.Channel |
channel() |
void |
channelActive(io.netty.channel.ChannelHandlerContext p_channelActive_1_) |
void |
channelInactive(io.netty.channel.ChannelHandlerContext p_channelInactive_1_) |
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext p_channelRead0_1_,
java.lang.Object p_channelRead0_2_) |
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext p_150728_1_,
Packet p_150728_2_) |
void |
closeChannel(IChatComponent p_150718_1_)
Closes the channel, the parameter can be used for an exit message (not certain how it gets sent)
|
void |
disableAutoRead()
Switches the channel to manual reading modus
|
void |
enableEncryption(javax.crypto.SecretKey p_150727_1_)
Adds an encoder+decoder to the channel pipeline.
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext p_exceptionCaught_1_,
java.lang.Throwable p_exceptionCaught_2_) |
IChatComponent |
getExitMessage()
If this channel is closed, returns the exit message, null otherwise.
|
INetHandler |
getNetHandler()
Gets the current handler for processing packets
|
java.net.SocketAddress |
getSocketAddress()
Return the InetSocketAddress of the remote endpoint
|
boolean |
isChannelOpen()
Returns true if this NetworkManager has an active channel, false otherwise
|
boolean |
isLocalChannel()
True if this NetworkManager uses a memory connection (single player game).
|
void |
processReceivedPackets()
Checks timeouts and processes all packets received
|
static NetworkManager |
provideLanClient(java.net.InetAddress p_150726_0_,
int p_150726_1_)
Prepares a clientside NetworkManager: establishes a connection to the address and port supplied and configures
the channel pipeline.
|
static NetworkManager |
provideLocalClient(java.net.SocketAddress p_150722_0_)
Prepares a clientside NetworkManager: establishes a connection to the socket supplied and configures the channel
pipeline.
|
void |
scheduleOutboundPacket(Packet p_150725_1_,
io.netty.util.concurrent.GenericFutureListener... p_150725_2_)
Will flush the outbound queue and dispatch the supplied Packet if the channel is ready, otherwise it adds the
packet to the outbound queue and registers the GenericFutureListener to fire after transmission
|
void |
setConnectionState(EnumConnectionState p_150723_1_)
Sets the new connection state and registers which packets this channel may send and receive
|
void |
setNetHandler(INetHandler p_150719_1_)
Sets the NetHandler for this NetworkManager, no checks are made if this handler is suitable for the particular
connection state (protocol)
|
acceptInboundMessage, channelRead
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
handlerAdded, handlerRemoved, isSharable
public static final org.apache.logging.log4j.Marker logMarkerNetwork
public static final org.apache.logging.log4j.Marker logMarkerPackets
public static final io.netty.util.AttributeKey attrKeyConnectionState
public static final io.netty.util.AttributeKey attrKeyReceivable
public static final io.netty.util.AttributeKey attrKeySendable
public static final io.netty.channel.nio.NioEventLoopGroup eventLoops
public void channelActive(io.netty.channel.ChannelHandlerContext p_channelActive_1_) throws java.lang.Exception
channelActive
in interface io.netty.channel.ChannelInboundHandler
channelActive
in class io.netty.channel.ChannelInboundHandlerAdapter
java.lang.Exception
public void setConnectionState(EnumConnectionState p_150723_1_)
public void channelInactive(io.netty.channel.ChannelHandlerContext p_channelInactive_1_)
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
public void exceptionCaught(io.netty.channel.ChannelHandlerContext p_exceptionCaught_1_, java.lang.Throwable p_exceptionCaught_2_)
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
protected void channelRead0(io.netty.channel.ChannelHandlerContext p_150728_1_, Packet p_150728_2_)
public void setNetHandler(INetHandler p_150719_1_)
public void scheduleOutboundPacket(Packet p_150725_1_, io.netty.util.concurrent.GenericFutureListener... p_150725_2_)
public void processReceivedPackets()
public java.net.SocketAddress getSocketAddress()
public void closeChannel(IChatComponent p_150718_1_)
public boolean isLocalChannel()
public static NetworkManager provideLanClient(java.net.InetAddress p_150726_0_, int p_150726_1_)
public static NetworkManager provideLocalClient(java.net.SocketAddress p_150722_0_)
public void enableEncryption(javax.crypto.SecretKey p_150727_1_)
public boolean isChannelOpen()
public INetHandler getNetHandler()
public IChatComponent getExitMessage()
public void disableAutoRead()
protected void channelRead0(io.netty.channel.ChannelHandlerContext p_channelRead0_1_, java.lang.Object p_channelRead0_2_)
channelRead0
in class io.netty.channel.SimpleChannelInboundHandler
public io.netty.channel.Channel channel()