public class NetworkManager extends io.netty.channel.SimpleChannelInboundHandler<IPacket<?>>
修飾子とタイプ | フィールドと説明 |
---|---|
static LazyValue<io.netty.channel.epoll.EpollEventLoopGroup> |
CLIENT_EPOLL_EVENTLOOP |
static LazyValue<io.netty.channel.DefaultEventLoopGroup> |
CLIENT_LOCAL_EVENTLOOP |
static LazyValue<io.netty.channel.nio.NioEventLoopGroup> |
CLIENT_NIO_EVENTLOOP |
static org.apache.logging.log4j.Marker |
NETWORK_MARKER |
static org.apache.logging.log4j.Marker |
NETWORK_PACKETS_MARKER |
static io.netty.util.AttributeKey<ProtocolType> |
PROTOCOL_ATTRIBUTE_KEY |
コンストラクタと説明 |
---|
NetworkManager(PacketDirection packetDirection) |
修飾子とタイプ | メソッドと説明 |
---|---|
io.netty.channel.Channel |
channel() |
void |
channelActive(io.netty.channel.ChannelHandlerContext p_channelActive_1_)
Calls
ChannelHandlerContext.fireChannelActive() to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
void |
channelInactive(io.netty.channel.ChannelHandlerContext p_channelInactive_1_)
Calls
ChannelHandlerContext.fireChannelInactive() to forward
to the next ChannelInboundHandler in the ChannelPipeline . |
protected void |
channelRead0(io.netty.channel.ChannelHandlerContext p_channelRead0_1_,
IPacket<?> p_channelRead0_2_)
Please keep in mind that this method will be renamed to
messageReceived(ChannelHandlerContext, I) in 5.0. |
void |
closeChannel(ITextComponent message)
Closes the channel, the parameter can be used for an exit message (not certain how it gets sent)
|
static NetworkManager |
createNetworkManagerAndConnect(java.net.InetAddress address,
int serverPort,
boolean useNativeTransport)
Create a new NetworkManager from the server host and connect it to the server
|
void |
disableAutoRead()
Switches the channel to manual reading modus
|
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_)
Calls
ChannelHandlerContext.fireExceptionCaught(Throwable) to forward
to the next ChannelHandler in the ChannelPipeline . |
PacketDirection |
getDirection() |
ITextComponent |
getExitMessage()
If this channel is closed, returns the exit message, null otherwise.
|
INetHandler |
getNetHandler()
Gets the current handler for processing packets
|
float |
getPacketsReceived() |
float |
getPacketsSent() |
java.net.SocketAddress |
getRemoteAddress()
Returns the socket address of the remote side.
|
void |
handleDisconnection() |
boolean |
hasNoChannel() |
boolean |
isChannelOpen()
Returns true if this NetworkManager has an active channel, false otherwise
|
boolean |
isEncrypted() |
boolean |
isLocalChannel()
True if this NetworkManager uses a memory connection (single player game).
|
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(IPacket<?> packetIn) |
void |
sendPacket(IPacket<?> packetIn,
io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> p_201058_2_) |
void |
setCompressionThreshold(int threshold) |
void |
setConnectionState(ProtocolType 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)
|
void |
tick()
Checks timeouts and processes all packets received
|
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggered
ensureNotSharable, handlerAdded, handlerRemoved, isSharable
public static final org.apache.logging.log4j.Marker NETWORK_MARKER
public static final org.apache.logging.log4j.Marker NETWORK_PACKETS_MARKER
public static final io.netty.util.AttributeKey<ProtocolType> PROTOCOL_ATTRIBUTE_KEY
public static final LazyValue<io.netty.channel.nio.NioEventLoopGroup> CLIENT_NIO_EVENTLOOP
public static final LazyValue<io.netty.channel.epoll.EpollEventLoopGroup> CLIENT_EPOLL_EVENTLOOP
public static final LazyValue<io.netty.channel.DefaultEventLoopGroup> CLIENT_LOCAL_EVENTLOOP
public NetworkManager(PacketDirection packetDirection)
public void channelActive(io.netty.channel.ChannelHandlerContext p_channelActive_1_) throws java.lang.Exception
io.netty.channel.ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelActive()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelActive
インタフェース内 io.netty.channel.ChannelInboundHandler
channelActive
クラス内 io.netty.channel.ChannelInboundHandlerAdapter
java.lang.Exception
public void setConnectionState(ProtocolType newState)
public void channelInactive(io.netty.channel.ChannelHandlerContext p_channelInactive_1_) throws java.lang.Exception
io.netty.channel.ChannelInboundHandlerAdapter
ChannelHandlerContext.fireChannelInactive()
to forward
to the next ChannelInboundHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.channelInactive
インタフェース内 io.netty.channel.ChannelInboundHandler
channelInactive
クラス内 io.netty.channel.ChannelInboundHandlerAdapter
java.lang.Exception
public void exceptionCaught(io.netty.channel.ChannelHandlerContext p_exceptionCaught_1_, java.lang.Throwable p_exceptionCaught_2_)
io.netty.channel.ChannelInboundHandlerAdapter
ChannelHandlerContext.fireExceptionCaught(Throwable)
to forward
to the next ChannelHandler
in the ChannelPipeline
.
Sub-classes may override this method to change behavior.exceptionCaught
インタフェース内 io.netty.channel.ChannelHandler
exceptionCaught
インタフェース内 io.netty.channel.ChannelInboundHandler
exceptionCaught
クラス内 io.netty.channel.ChannelInboundHandlerAdapter
protected void channelRead0(io.netty.channel.ChannelHandlerContext p_channelRead0_1_, IPacket<?> p_channelRead0_2_) throws java.lang.Exception
io.netty.channel.SimpleChannelInboundHandler
messageReceived(ChannelHandlerContext, I)
in 5.0.
Is called for each message of type I
.channelRead0
クラス内 io.netty.channel.SimpleChannelInboundHandler<IPacket<?>>
p_channelRead0_1_
- the ChannelHandlerContext
which this SimpleChannelInboundHandler
belongs top_channelRead0_2_
- the message to handlejava.lang.Exception
- is thrown if an error occurredpublic void setNetHandler(INetHandler handler)
public void sendPacket(IPacket<?> packetIn)
public void sendPacket(IPacket<?> packetIn, @Nullable io.netty.util.concurrent.GenericFutureListener<? extends io.netty.util.concurrent.Future<? super java.lang.Void>> p_201058_2_)
public void tick()
public java.net.SocketAddress getRemoteAddress()
public void closeChannel(ITextComponent message)
public boolean isLocalChannel()
public static NetworkManager createNetworkManagerAndConnect(java.net.InetAddress address, int serverPort, boolean useNativeTransport)
public static NetworkManager provideLocalClient(java.net.SocketAddress address)
public void enableEncryption(javax.crypto.SecretKey key)
public boolean isEncrypted()
public boolean isChannelOpen()
public boolean hasNoChannel()
public INetHandler getNetHandler()
@Nullable public ITextComponent getExitMessage()
public void disableAutoRead()
public void setCompressionThreshold(int threshold)
public void handleDisconnection()
public float getPacketsReceived()
public float getPacketsSent()
public io.netty.channel.Channel channel()
public PacketDirection getDirection()