Class DefaultServer.Connection

java.lang.Object
com.jme3.network.base.DefaultServer.Connection
All Implemented Interfaces:
HostedConnection, MessageConnection
Enclosing class:
DefaultServer

protected class DefaultServer.Connection extends Object implements HostedConnection
Hosted connection implementation backed by one or more endpoints.
Author:
Paul Speed
  • Constructor Details

    • Connection

      public Connection(int channelCount)
      Creates a hosted connection state holder.
      Parameters:
      channelCount - the number of endpoint slots to allocate
  • Method Details

    • getServer

      public Server getServer()
      Description copied from interface: HostedConnection
      Returns the Server instance that is hosting this connection.
      Specified by:
      getServer in interface HostedConnection
      Returns:
      the owning server
    • getId

      public int getId()
      Description copied from interface: HostedConnection
      Returns the server-unique ID for this client.
      Specified by:
      getId in interface HostedConnection
      Returns:
      the hosted connection id
    • getAddress

      public String getAddress()
      Description copied from interface: HostedConnection
      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.
      Specified by:
      getAddress in interface HostedConnection
      Returns:
      the remote address string
    • send

      public void send(Message message)
      Description copied from interface: MessageConnection
      Sends a message to the other end of the connection.
      Specified by:
      send in interface MessageConnection
      Parameters:
      message - the message to send
    • send

      public void send(int channel, Message message)
      Description copied from interface: MessageConnection
      Sends a message to the other end of the connection using the specified alternate channel.
      Specified by:
      send in interface MessageConnection
      Parameters:
      channel - the transport channel to use
      message - the message to send
    • closeConnection

      protected void closeConnection()
      Closes all endpoints associated with this hosted connection.
    • close

      public void close(String reason)
      Description copied from interface: HostedConnection
      Closes and removes this connection from the server sending the optional reason to the remote client.
      Specified by:
      close in interface HostedConnection
      Parameters:
      reason - the optional disconnect reason
    • setAttribute

      public Object setAttribute(String name, Object value)
      Description copied from interface: HostedConnection
      Sets a session attribute specific to this connection. If the value is set to null then the attribute is removed.
      Specified by:
      setAttribute in interface HostedConnection
      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

      public <T> T getAttribute(String name)
      Description copied from interface: HostedConnection
      Retrieves a previously stored session attribute or null if no such attribute exists.
      Specified by:
      getAttribute in interface HostedConnection
      Type Parameters:
      T - the expected attribute type
      Parameters:
      name - the attribute name
      Returns:
      the stored attribute value, or null if none exists
    • attributeNames

      public Set<String> attributeNames()
      Description copied from interface: HostedConnection
      Returns a read-only set of attribute names currently stored for this client session.
      Specified by:
      attributeNames in interface HostedConnection
      Returns:
      the current attribute names
    • toString

      public String toString()
      Overrides:
      toString in class Object