Class DefaultServer.Connection
java.lang.Object
com.jme3.network.base.DefaultServer.Connection
- All Implemented Interfaces:
HostedConnection, MessageConnection
- Enclosing class:
DefaultServer
Hosted connection implementation backed by one or more endpoints.
- Author:
- Paul Speed
-
Field Summary
Fields inherited from interface MessageConnection
CHANNEL_DEFAULT_RELIABLE, CHANNEL_DEFAULT_UNRELIABLE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a read-only set of attribute names currently stored for this client session.voidCloses and removes this connection from the server sending the optional reason to the remote client.protected voidCloses all endpoints associated with this hosted connection.Returns the transport specific remote address of this connection as a string.<T> TgetAttribute(String name) Retrieves a previously stored session attribute or null if no such attribute exists.intgetId()Returns the server-unique ID for this client.Returns the Server instance that is hosting this connection.voidSends a message to the other end of the connection using the specified alternate channel.voidSends a message to the other end of the connection.setAttribute(String name, Object value) Sets a session attribute specific to this connection.toString()
-
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
Description copied from interface:HostedConnectionReturns the Server instance that is hosting this connection.- Specified by:
getServerin interfaceHostedConnection- Returns:
- the owning server
-
getId
public int getId()Description copied from interface:HostedConnectionReturns the server-unique ID for this client.- Specified by:
getIdin interfaceHostedConnection- Returns:
- the hosted connection id
-
getAddress
Description copied from interface:HostedConnectionReturns 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:
getAddressin interfaceHostedConnection- Returns:
- the remote address string
-
send
Description copied from interface:MessageConnectionSends a message to the other end of the connection.- Specified by:
sendin interfaceMessageConnection- Parameters:
message- the message to send
-
send
Description copied from interface:MessageConnectionSends a message to the other end of the connection using the specified alternate channel.- Specified by:
sendin interfaceMessageConnection- Parameters:
channel- the transport channel to usemessage- the message to send
-
closeConnection
protected void closeConnection()Closes all endpoints associated with this hosted connection. -
close
Description copied from interface:HostedConnectionCloses and removes this connection from the server sending the optional reason to the remote client.- Specified by:
closein interfaceHostedConnection- Parameters:
reason- the optional disconnect reason
-
setAttribute
Description copied from interface:HostedConnectionSets a session attribute specific to this connection. If the value is set to null then the attribute is removed.- Specified by:
setAttributein interfaceHostedConnection- Parameters:
name- the attribute namevalue- 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
Description copied from interface:HostedConnectionRetrieves a previously stored session attribute or null if no such attribute exists.- Specified by:
getAttributein interfaceHostedConnection- Type Parameters:
T- the expected attribute type- Parameters:
name- the attribute name- Returns:
- the stored attribute value, or null if none exists
-
attributeNames
Description copied from interface:HostedConnectionReturns a read-only set of attribute names currently stored for this client session.- Specified by:
attributeNamesin interfaceHostedConnection- Returns:
- the current attribute names
-
toString
-