Class TcpSession
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<Packet>
org.geysermc.mcprotocollib.network.tcp.TcpSession
- All Implemented Interfaces:
io.netty.channel.ChannelHandler,io.netty.channel.ChannelInboundHandler,Session
- Direct Known Subclasses:
TcpClientSession,TcpServerSession
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected booleanprotected Stringprotected intstatic booleanControls whether non-priority packets are handled in a separate event loop -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(SessionListener listener) Adds a listener to this session.voidcallEvent(SessionEvent event) Calls an event on the listeners of this session.voidcallPacketReceived(Packet packet) Notifies all listeners that a packet was just received.voidcallPacketSent(Packet packet) Notifies all listeners that a packet was just sent.voidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) protected voidchannelRead0(io.netty.channel.ChannelHandlerContext ctx, Packet packet) voidconnect()Connects this session to its host and port.voidconnect(boolean wait) Connects this session to its host and port.voidconnect(boolean wait, boolean transferring) Connects this session to its host and port.voiddisconnect(@NonNull net.kyori.adventure.text.Component reason, @Nullable Throwable cause) Disconnects the session.voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) io.netty.channel.Channel<T> TGets the value of the given flag as an instance of the given type.<T> TGets the value of the given flag as an instance of the given type.getFlags()Gets this session's set flags.getHost()Gets the host the session is connected to.Gets the listeners listening on this session.Gets the local address of the session.Gets the packet protocol of the session.intgetPort()Gets the port the session is connected to.Gets the remote address of the session.booleanChecks whether this session has a flag set.booleanReturns true if the session is connected.voidremoveListener(SessionListener listener) Removes a listener from this session.voidSends a packet.voidsetCompression(@Nullable CompressionConfig compressionConfig) Sets the compression config for this session.voidsetEncryption(@Nullable EncryptionConfig encryptionConfig) Sets encryption for this session.<T> voidSets the value of a flag.voidSets the values for a collection of flags.Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemovedMethods inherited from interface org.geysermc.mcprotocollib.network.Session
disconnect, disconnect, disconnect, getCodecHelper
-
Field Details
-
USE_EVENT_LOOP_FOR_PACKETS
public static boolean USE_EVENT_LOOP_FOR_PACKETSControls whether non-priority packets are handled in a separate event loop -
host
-
port
protected int port -
disconnected
protected boolean disconnected
-
-
Constructor Details
-
TcpSession
-
-
Method Details
-
connect
public void connect()Description copied from interface:SessionConnects this session to its host and port. -
connect
public void connect(boolean wait) Description copied from interface:SessionConnects this session to its host and port. -
connect
public void connect(boolean wait, boolean transferring) Description copied from interface:SessionConnects this session to its host and port. -
getHost
Description copied from interface:SessionGets the host the session is connected to. -
getPort
public int getPort()Description copied from interface:SessionGets the port the session is connected to. -
getLocalAddress
Description copied from interface:SessionGets the local address of the session.- Specified by:
getLocalAddressin interfaceSession- Returns:
- The local address, or null if the session is not connected.
-
getRemoteAddress
Description copied from interface:SessionGets the remote address of the session.- Specified by:
getRemoteAddressin interfaceSession- Returns:
- The remote address, or null if the session is not connected.
-
getPacketProtocol
Description copied from interface:SessionGets the packet protocol of the session.- Specified by:
getPacketProtocolin interfaceSession- Returns:
- The session's packet protocol.
-
getFlags
Description copied from interface:SessionGets this session's set flags. If this session belongs to a server, the server's flags will be included in the results. -
hasFlag
Description copied from interface:SessionChecks whether this session has a flag set. If this session belongs to a server, the server's flags will also be checked. -
getFlag
Description copied from interface:SessionGets the value of the given flag as an instance of the given type. If this session belongs to a server, the server's flags will be checked for the flag as well. -
getFlag
Description copied from interface:SessionGets the value of the given flag as an instance of the given type. If this session belongs to a server, the server's flags will be checked for the flag as well. If the flag is not set, the specified default value will be returned. -
setFlag
Description copied from interface:SessionSets the value of a flag. This does not change a server's flags if this session belongs to a server. -
setFlags
Description copied from interface:SessionSets the values for a collection of flags. -
getListeners
Description copied from interface:SessionGets the listeners listening on this session.- Specified by:
getListenersin interfaceSession- Returns:
- This session's listeners.
-
addListener
Description copied from interface:SessionAdds a listener to this session.- Specified by:
addListenerin interfaceSession- Parameters:
listener- Listener to add.
-
removeListener
Description copied from interface:SessionRemoves a listener from this session.- Specified by:
removeListenerin interfaceSession- Parameters:
listener- Listener to remove.
-
callEvent
Description copied from interface:SessionCalls an event on the listeners of this session. -
callPacketReceived
Description copied from interface:SessionNotifies all listeners that a packet was just received.- Specified by:
callPacketReceivedin interfaceSession- Parameters:
packet- Packet to notify.
-
callPacketSent
Description copied from interface:SessionNotifies all listeners that a packet was just sent.- Specified by:
callPacketSentin interfaceSession- Parameters:
packet- Packet to notify.
-
setCompression
Description copied from interface:SessionSets the compression config for this session.- Specified by:
setCompressionin interfaceSession- Parameters:
compressionConfig- the compression to compress with, or null to disable compression
-
setEncryption
Description copied from interface:SessionSets encryption for this session.- Specified by:
setEncryptionin interfaceSession- Parameters:
encryptionConfig- the encryption to encrypt with, or null to disable encryption
-
isConnected
public boolean isConnected()Description copied from interface:SessionReturns true if the session is connected.- Specified by:
isConnectedin interfaceSession- Returns:
- True if the session is connected.
-
send
Description copied from interface:SessionSends a packet. -
disconnect
public void disconnect(@NonNull net.kyori.adventure.text.Component reason, @Nullable Throwable cause) Description copied from interface:SessionDisconnects the session.- Specified by:
disconnectin interfaceSession- Parameters:
reason- Reason for disconnecting.cause- Throwable responsible for disconnecting.
-
getChannel
public io.netty.channel.Channel getChannel() -
channelActive
- Specified by:
channelActivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelActivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelInactive
- Specified by:
channelInactivein interfaceio.netty.channel.ChannelInboundHandler- Overrides:
channelInactivein classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
exceptionCaught
- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter
-
channelRead0
- Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<Packet>
-