Package net.glowstone.net
Class GlowSession
java.lang.Object
com.flowpowered.network.session.BasicSession
net.glowstone.net.GlowSession
- All Implemented Interfaces:
com.flowpowered.network.session.Session
public class GlowSession
extends com.flowpowered.network.session.BasicSession
A single connection to the server, which may or may not be associated with a player.
-
Constructor Summary
ConstructorsConstructorDescriptionGlowSession(GlowServer server, ProtocolProvider protocolProvider, io.netty.channel.Channel channel, com.flowpowered.network.ConnectionManager connectionManager) Creates a new session. -
Method Summary
Modifier and TypeMethodDescriptionvoidDeprecated.voiddisconnect(String reason) Disconnects the session with the specified reason.voiddisconnect(String reason, boolean overrideKick) Disconnects the session with the specified reason.voidenableCompression(int threshold) Enables compression if not already enabled.voidenableEncryption(SecretKey sharedSecret) Enables encryption or changes the session key.The remote address of the connection.The player associated with this session (if there is one).Data regarding a user who has connected through a proxy, used to provide online-mode UUID and properties and other data even if the server is running in offline mode.The server this session belongs to.byte[]The randomly-generated verify token used in authentication for this session.The verify username used in authentication.intThe version used to connect.The hostname/port the player used to connect to the server.voididle()Notify that the session is currently idle.booleanisOnline()The state of the connection.voidmessageReceived(com.flowpowered.network.Message message) voidvoidonHandlerThrowable(com.flowpowered.network.Message message, com.flowpowered.network.MessageHandler<?, ?> handle, Throwable t) voidvoidvoidpong(long pingId) Note that the client has responded to a keep-alive.voidsendAndRelease(com.flowpowered.network.Message message, io.netty.buffer.ByteBuf buf) Send the message and release the specified byte buffer after it is sent.voidsendAndRelease(com.flowpowered.network.Message message, io.netty.buffer.ByteBuf... bufs) Send the message and release the specified byte buffers after it is sent.io.netty.channel.ChannelFuturesendWithFuture(com.flowpowered.network.Message message) voidsetPlayer(GlowPlayerProfile profile) Sets the player associated with this session.voidsetProtocol(com.flowpowered.network.protocol.AbstractProtocol proto) Sets the protocol for this session.voidsetProxyData(ProxyData proxyData) Set theProxyDatafor this session.voidsetVerifyToken(byte[] verifyToken) The randomly-generated verify token used in authentication for this session.voidsetVerifyUsername(String verifyUsername) The verify username used in authentication.voidsetVersion(int version) Sets the version.voidsetVirtualHost(InetSocketAddress virtualHost) The hostname/port the player used to connect to the server.toString()Methods inherited from class com.flowpowered.network.session.BasicSession
getChannel, getLogger, getProcessor, getProtocol, getSessionId, isActive, onReady, send, sendAll, setOption
-
Constructor Details
-
GlowSession
public GlowSession(GlowServer server, ProtocolProvider protocolProvider, io.netty.channel.Channel channel, com.flowpowered.network.ConnectionManager connectionManager) Creates a new session.- Parameters:
server- The server this session belongs to.channel- The channel associated with this session.connectionManager- The connection manager to manage connections for this session.
-
-
Method Details
-
setProxyData
Set theProxyDatafor this session.- Parameters:
proxyData- The proxy data to use.
-
setVersion
public void setVersion(int version) Sets the version. Must only be called once.- Parameters:
version- the version- Throws:
IllegalStateException- if the version has already been set
-
idle
public void idle()Notify that the session is currently idle. -
pong
public void pong(long pingId) Note that the client has responded to a keep-alive.- Parameters:
pingId- The pingId to check for validity.
-
setPlayer
Sets the player associated with this session.- Parameters:
profile- The player's profile with name and UUID information.- Throws:
IllegalStateException- if there is already a player associated with this session.
-
sendWithFuture
public io.netty.channel.ChannelFuture sendWithFuture(com.flowpowered.network.Message message) - Overrides:
sendWithFuturein classcom.flowpowered.network.session.BasicSession
-
sendAndRelease
public void sendAndRelease(com.flowpowered.network.Message message, io.netty.buffer.ByteBuf buf) Send the message and release the specified byte buffer after it is sent.- Parameters:
message- The message.buf- The byte buffer.
-
sendAndRelease
public void sendAndRelease(com.flowpowered.network.Message message, io.netty.buffer.ByteBuf... bufs) Send the message and release the specified byte buffers after it is sent.- Parameters:
message- The message.bufs- The byte buffers.
-
disconnect
Deprecated.- Specified by:
disconnectin interfacecom.flowpowered.network.session.Session- Overrides:
disconnectin classcom.flowpowered.network.session.BasicSession
-
disconnect
Disconnects the session with the specified reason.This causes a KickMessage to be sent. When it has been delivered, the channel is closed.
- Parameters:
reason- The reason for disconnection.
-
disconnect
Disconnects the session with the specified reason.This causes a KickMessage to be sent. When it has been delivered, the channel is closed.
- Parameters:
reason- The reason for disconnection.overrideKick- Whether to skip the kick event.
-
setProtocol
public void setProtocol(com.flowpowered.network.protocol.AbstractProtocol proto) Sets the protocol for this session.- Overrides:
setProtocolin classcom.flowpowered.network.session.BasicSession- Parameters:
proto- the new protocol
-
enableEncryption
Enables encryption or changes the session key.- Parameters:
sharedSecret- the new session key
-
enableCompression
public void enableCompression(int threshold) Enables compression if not already enabled.- Parameters:
threshold- the minimum message size in bytes to compress
-
onDisconnect
public void onDisconnect()- Specified by:
onDisconnectin interfacecom.flowpowered.network.session.Session- Overrides:
onDisconnectin classcom.flowpowered.network.session.BasicSession
-
messageReceived
public void messageReceived(com.flowpowered.network.Message message) - Specified by:
messageReceivedin interfacecom.flowpowered.network.session.Session- Overrides:
messageReceivedin classcom.flowpowered.network.session.BasicSession
-
onInboundThrowable
- Specified by:
onInboundThrowablein interfacecom.flowpowered.network.session.Session- Overrides:
onInboundThrowablein classcom.flowpowered.network.session.BasicSession
-
onOutboundThrowable
- Overrides:
onOutboundThrowablein classcom.flowpowered.network.session.BasicSession
-
onHandlerThrowable
public void onHandlerThrowable(com.flowpowered.network.Message message, com.flowpowered.network.MessageHandler<?, ?> handle, Throwable t) - Overrides:
onHandlerThrowablein classcom.flowpowered.network.session.BasicSession
-
toString
- Overrides:
toStringin classcom.flowpowered.network.session.BasicSession
-
getServer
The server this session belongs to.- Returns:
- The server.
-
getAddress
The remote address of the connection.- Overrides:
getAddressin classcom.flowpowered.network.session.BasicSession
-
isOnline
public boolean isOnline()The state of the connection.- Returns:
- true if this session's state is online
-
getVerifyToken
public byte[] getVerifyToken()The randomly-generated verify token used in authentication for this session.- Returns:
- The verify token
-
setVerifyToken
public void setVerifyToken(byte[] verifyToken) The randomly-generated verify token used in authentication for this session.- Parameters:
verifyToken- the verify token
-
getVerifyUsername
The verify username used in authentication. -
setVerifyUsername
The verify username used in authentication. -
getVirtualHost
The hostname/port the player used to connect to the server. -
setVirtualHost
The hostname/port the player used to connect to the server. -
getVersion
public int getVersion()The version used to connect. -
getProxyData
Data regarding a user who has connected through a proxy, used to provide online-mode UUID and properties and other data even if the server is running in offline mode.Null for non-proxied sessions.
- Returns:
- The proxy data to use, or null for an unproxied connection.
-
getPlayer
The player associated with this session (if there is one).- Returns:
- The player, or
nullif no player is associated with this session.
-