Interface HostedConnection

All Superinterfaces:
MessageConnection
All Known Implementing Classes:
DefaultServer.Connection

public interface HostedConnection extends MessageConnection
This is the connection back to a client that is being hosted in a server instance.
Author:
Paul Speed
  • Method Details

    • getServer

      Server getServer()
      Returns the Server instance that is hosting this connection.
      Returns:
      the owning server
    • getId

      int getId()
      Returns the server-unique ID for this client.
      Returns:
      the hosted connection id
    • getAddress

      String getAddress()
      Returns the transport specific remote address of this connection as a string. This may or may not be unique per connection depending on the type of transport. It is provided for information and filtering purposes.
      Returns:
      the remote address string
    • close

      void close(String reason)
      Closes and removes this connection from the server sending the optional reason to the remote client.
      Parameters:
      reason - the optional disconnect reason
    • setAttribute

      Object setAttribute(String name, Object value)
      Sets a session attribute specific to this connection. If the value is set to null then the attribute is removed.
      Parameters:
      name - the attribute name
      value - the attribute value, or null to remove it
      Returns:
      The previous session value for this key or null if there was no previous value.
    • getAttribute

      <T> T getAttribute(String name)
      Retrieves a previously stored session attribute or null if no such attribute exists.
      Type Parameters:
      T - the expected attribute type
      Parameters:
      name - the attribute name
      Returns:
      the stored attribute value, or null if none exists
    • attributeNames

      Set<String> attributeNames()
      Returns a read-only set of attribute names currently stored for this client session.
      Returns:
      the current attribute names