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
ConstructorDescriptionGlowSession
(GlowServer server, ProtocolProvider protocolProvider, io.netty.channel.Channel channel, com.flowpowered.network.ConnectionManager connectionManager) Creates a new session. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Deprecated.void
disconnect
(String reason) Disconnects the session with the specified reason.void
disconnect
(String reason, boolean overrideKick) Disconnects the session with the specified reason.void
enableCompression
(int threshold) Enables compression if not already enabled.void
enableEncryption
(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.int
The version used to connect.The hostname/port the player used to connect to the server.void
idle()
Notify that the session is currently idle.boolean
isOnline()
The state of the connection.void
messageReceived
(com.flowpowered.network.Message message) void
void
onHandlerThrowable
(com.flowpowered.network.Message message, com.flowpowered.network.MessageHandler<?, ?> handle, Throwable t) void
void
void
pong
(long pingId) Note that the client has responded to a keep-alive.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.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.io.netty.channel.ChannelFuture
sendWithFuture
(com.flowpowered.network.Message message) void
setPlayer
(GlowPlayerProfile profile) Sets the player associated with this session.void
setProtocol
(com.flowpowered.network.protocol.AbstractProtocol proto) Sets the protocol for this session.void
setProxyData
(ProxyData proxyData) Set theProxyData
for this session.void
setVerifyToken
(byte[] verifyToken) The randomly-generated verify token used in authentication for this session.void
setVerifyUsername
(String verifyUsername) The verify username used in authentication.void
setVersion
(int version) Sets the version.void
setVirtualHost
(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 theProxyData
for 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:
sendWithFuture
in 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:
disconnect
in interfacecom.flowpowered.network.session.Session
- Overrides:
disconnect
in 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:
setProtocol
in 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:
onDisconnect
in interfacecom.flowpowered.network.session.Session
- Overrides:
onDisconnect
in classcom.flowpowered.network.session.BasicSession
-
messageReceived
public void messageReceived(com.flowpowered.network.Message message) - Specified by:
messageReceived
in interfacecom.flowpowered.network.session.Session
- Overrides:
messageReceived
in classcom.flowpowered.network.session.BasicSession
-
onInboundThrowable
- Specified by:
onInboundThrowable
in interfacecom.flowpowered.network.session.Session
- Overrides:
onInboundThrowable
in classcom.flowpowered.network.session.BasicSession
-
onOutboundThrowable
- Overrides:
onOutboundThrowable
in classcom.flowpowered.network.session.BasicSession
-
onHandlerThrowable
public void onHandlerThrowable(com.flowpowered.network.Message message, com.flowpowered.network.MessageHandler<?, ?> handle, Throwable t) - Overrides:
onHandlerThrowable
in classcom.flowpowered.network.session.BasicSession
-
toString
- Overrides:
toString
in classcom.flowpowered.network.session.BasicSession
-
getServer
The server this session belongs to.- Returns:
- The server.
-
getAddress
The remote address of the connection.- Overrides:
getAddress
in 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
null
if no player is associated with this session.
-