public class NetworkManager extends io.netty.channel.SimpleChannelInboundHandler<Packet>
Modifier and Type | Class and Description |
---|---|
(package private) static class |
NetworkManager.InboundHandlerTuplePacketListener |
Modifier and Type | Field and Description |
---|---|
static io.netty.util.AttributeKey<EnumConnectionState> |
attrKeyConnectionState |
private io.netty.channel.Channel |
channel
The active channel
|
static LazyLoadBase<io.netty.channel.local.LocalEventLoopGroup> |
CLIENT_LOCAL_EVENTLOOP |
static LazyLoadBase<io.netty.channel.nio.NioEventLoopGroup> |
CLIENT_NIO_EVENTLOOP |
private EnumPacketDirection |
direction |
private boolean |
disconnected |
static LazyLoadBase<io.netty.channel.epoll.EpollEventLoopGroup> |
field_181125_e |
private java.util.concurrent.locks.ReentrantReadWriteLock |
field_181680_j |
private boolean |
isEncrypted |
private static org.apache.logging.log4j.Logger |
logger |
static org.apache.logging.log4j.Marker |
logMarkerNetwork |
static org.apache.logging.log4j.Marker |
logMarkerPackets |
private java.util.Queue<NetworkManager.InboundHandlerTuplePacketListener> |
outboundPacketsQueue |
private INetHandler |
packetListener
The INetHandler instance responsible for processing received packets
|
private java.net.SocketAddress |
socketAddress
The address of the remote party
|
private IChatComponent |
terminationReason
A String indicating why the network has shutdown.
|
Constructor and Description |
---|
NetworkManager(EnumPacketDirection packetDirection) |
Modifier and Type | Method and Description |
---|---|
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_,
Packet p_channelRead0_2_) |
void |
checkDisconnected() |
void |
closeChannel(IChatComponent message)
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
|
private void |
dispatchPacket(Packet inPacket,
io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>[] futureListeners)
Will commit the packet to the channel.
|
void |
enableEncryption(javax.crypto.SecretKey key)
Adds an encoder+decoder to the channel pipeline.
|
void |
exceptionCaught(io.netty.channel.ChannelHandlerContext p_exceptionCaught_1_,
java.lang.Throwable p_exceptionCaught_2_) |
private void |
flushOutboundQueue()
Will iterate through the outboundPacketQueue and dispatch all Packets
|
static NetworkManager |
func_181124_a(java.net.InetAddress p_181124_0_,
int p_181124_1_,
boolean p_181124_2_) |
IChatComponent |
getExitMessage()
If this channel is closed, returns the exit message, null otherwise.
|
boolean |
getIsencrypted() |
INetHandler |
getNetHandler()
Gets the current handler for processing packets
|
java.net.SocketAddress |
getRemoteAddress()
Returns the socket address of the remote side.
|
boolean |
hasNoChannel() |
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 |
provideLocalClient(java.net.SocketAddress address)
Prepares a clientside NetworkManager: establishes a connection to the socket supplied and configures the channel
pipeline.
|
void |
sendPacket(Packet packetIn) |
void |
sendPacket(Packet packetIn,
io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener,
io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners) |
void |
setCompressionTreshold(int treshold) |
void |
setConnectionState(EnumConnectionState newState)
Sets the new connection state and registers which packets this channel may send and receive
|
void |
setNetHandler(INetHandler handler)
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
private static final org.apache.logging.log4j.Logger logger
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<EnumConnectionState> attrKeyConnectionState
public static final LazyLoadBase<io.netty.channel.nio.NioEventLoopGroup> CLIENT_NIO_EVENTLOOP
public static final LazyLoadBase<io.netty.channel.epoll.EpollEventLoopGroup> field_181125_e
public static final LazyLoadBase<io.netty.channel.local.LocalEventLoopGroup> CLIENT_LOCAL_EVENTLOOP
private final EnumPacketDirection direction
private final java.util.Queue<NetworkManager.InboundHandlerTuplePacketListener> outboundPacketsQueue
private final java.util.concurrent.locks.ReentrantReadWriteLock field_181680_j
private io.netty.channel.Channel channel
private java.net.SocketAddress socketAddress
private INetHandler packetListener
private IChatComponent terminationReason
private boolean isEncrypted
private boolean disconnected
public NetworkManager(EnumPacketDirection packetDirection)
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 newState)
public void channelInactive(io.netty.channel.ChannelHandlerContext p_channelInactive_1_) throws java.lang.Exception
channelInactive
in interface io.netty.channel.ChannelInboundHandler
channelInactive
in class io.netty.channel.ChannelInboundHandlerAdapter
java.lang.Exception
public void exceptionCaught(io.netty.channel.ChannelHandlerContext p_exceptionCaught_1_, java.lang.Throwable p_exceptionCaught_2_) throws java.lang.Exception
exceptionCaught
in interface io.netty.channel.ChannelHandler
exceptionCaught
in interface io.netty.channel.ChannelInboundHandler
exceptionCaught
in class io.netty.channel.ChannelInboundHandlerAdapter
java.lang.Exception
protected void channelRead0(io.netty.channel.ChannelHandlerContext p_channelRead0_1_, Packet p_channelRead0_2_) throws java.lang.Exception
channelRead0
in class io.netty.channel.SimpleChannelInboundHandler<Packet>
java.lang.Exception
public void setNetHandler(INetHandler handler)
public void sendPacket(Packet packetIn)
public void sendPacket(Packet packetIn, io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> listener, io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>... listeners)
private void dispatchPacket(Packet inPacket, io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>>[] futureListeners)
private void flushOutboundQueue()
public void processReceivedPackets()
public java.net.SocketAddress getRemoteAddress()
public void closeChannel(IChatComponent message)
public boolean isLocalChannel()
public static NetworkManager func_181124_a(java.net.InetAddress p_181124_0_, int p_181124_1_, boolean p_181124_2_)
public static NetworkManager provideLocalClient(java.net.SocketAddress address)
public void enableEncryption(javax.crypto.SecretKey key)
public boolean getIsencrypted()
public boolean isChannelOpen()
public boolean hasNoChannel()
public INetHandler getNetHandler()
public IChatComponent getExitMessage()
public void disableAutoRead()
public void setCompressionTreshold(int treshold)
public void checkDisconnected()