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 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

      public void setProxyData(ProxyData proxyData)
      Set the ProxyData 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

      public void setPlayer(GlowPlayerProfile profile)
      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 class com.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 public void disconnect()
      Deprecated.
      Specified by:
      disconnect in interface com.flowpowered.network.session.Session
      Overrides:
      disconnect in class com.flowpowered.network.session.BasicSession
    • disconnect

      public void disconnect(String reason)
      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

      public void disconnect(String reason, boolean overrideKick)
      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 class com.flowpowered.network.session.BasicSession
      Parameters:
      proto - the new protocol
    • enableEncryption

      public void enableEncryption(SecretKey sharedSecret)
      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 interface com.flowpowered.network.session.Session
      Overrides:
      onDisconnect in class com.flowpowered.network.session.BasicSession
    • messageReceived

      public void messageReceived(com.flowpowered.network.Message message)
      Specified by:
      messageReceived in interface com.flowpowered.network.session.Session
      Overrides:
      messageReceived in class com.flowpowered.network.session.BasicSession
    • onInboundThrowable

      public void onInboundThrowable(Throwable t)
      Specified by:
      onInboundThrowable in interface com.flowpowered.network.session.Session
      Overrides:
      onInboundThrowable in class com.flowpowered.network.session.BasicSession
    • onOutboundThrowable

      public void onOutboundThrowable(Throwable t)
      Overrides:
      onOutboundThrowable in class com.flowpowered.network.session.BasicSession
    • onHandlerThrowable

      public void onHandlerThrowable(com.flowpowered.network.Message message, com.flowpowered.network.MessageHandler<?,?> handle, Throwable t)
      Overrides:
      onHandlerThrowable in class com.flowpowered.network.session.BasicSession
    • toString

      public String toString()
      Overrides:
      toString in class com.flowpowered.network.session.BasicSession
    • getServer

      public GlowServer getServer()
      The server this session belongs to.
      Returns:
      The server.
    • getAddress

      public InetSocketAddress getAddress()
      The remote address of the connection.
      Overrides:
      getAddress in class com.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

      public String getVerifyUsername()
      The verify username used in authentication.
    • setVerifyUsername

      public void setVerifyUsername(String verifyUsername)
      The verify username used in authentication.
    • getVirtualHost

      public InetSocketAddress getVirtualHost()
      The hostname/port the player used to connect to the server.
    • setVirtualHost

      public void setVirtualHost(InetSocketAddress virtualHost)
      The hostname/port the player used to connect to the server.
    • getVersion

      public int getVersion()
      The version used to connect.
    • getProxyData

      public ProxyData 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

      public GlowPlayer getPlayer()
      The player associated with this session (if there is one).
      Returns:
      The player, or null if no player is associated with this session.