Interface ISocketContext


public interface ISocketContext
Represents a WebSocket connection
  • Method Details

    • getSessionId

      @NonNull java.lang.String getSessionId()
      Returns:
      The session ID of the connection
    • getUserId

      long getUserId()
      Returns:
      the User ID of the Client.
    • getClientName

      @Nullable java.lang.String getClientName()
      Returns:
      the name of the Client, or null if it was not specified.
    • getPlayer

      IPlayer getPlayer​(long guildId)
      Returns the player of a guild. Never returns null.
      Parameters:
      guildId - the guild the player is associated with
      Returns:
      a potentially newly-created player
    • getPlayers

      java.util.Map<java.lang.Long,​IPlayer> getPlayers()
      Returns:
      a read-only map of all players associated by their guild
    • destroyPlayer

      void destroyPlayer​(long guildId)
      Parameters:
      guildId - guild for which to remove player state from
    • sendMessage

      @Deprecated void sendMessage​(org.json.JSONObject message)
      Deprecated.
      As of v3.7 Jackson is the preferred way of JSON serialization, use sendMessage(Object) instead.
      Parameters:
      message - a JSON message to send to the WebSocket client
    • sendMessage

      void sendMessage​(java.lang.Object message)
      Parameters:
      message - a message to send to the WebSocket client, it should be compatible with Jackson.
    • getState

      Returns:
      the state of the context
    • closeWebSocket

      void closeWebSocket()
      Closes this WebSocket
    • closeWebSocket

      void closeWebSocket​(int closeCode)
      Parameters:
      closeCode - the close code to send to the client
    • closeWebSocket

      void closeWebSocket​(int closeCode, java.lang.String reason)
      Parameters:
      closeCode - the close code to send to the client
      reason - the close reason to send to the client