public abstract class AbstractHostedConnectionService extends AbstractHostedService
Subclasses must at least override the onInitialize(), startHostingOnConnection(), and stopHostingOnConnection() methods to handle service and connection initialization.
An autoHost flag controls whether startHostingOnConnection() is called automatically when new connections are detected. If autoHohst is false then it is up to the implementation or appliction to specifically start hosting at some point.
Modifier | Constructor and Description |
---|---|
protected |
AbstractHostedConnectionService()
Creates a new HostedService that will autohost connections
when detected.
|
protected |
AbstractHostedConnectionService(boolean autoHost)
Creates a new HostedService that will automatically host
connections only if autoHost is true.
|
Modifier and Type | Method and Description |
---|---|
void |
connectionAdded(Server server,
HostedConnection hc)
Called internally when a new connection is detected for
the server.
|
void |
connectionRemoved(Server server,
HostedConnection hc)
Called internally when an existing connection is leaving
the server.
|
boolean |
getAutoHost()
Returns true if this service automatically attaches
hosting capabilities to new connections.
|
void |
setAutoHost(boolean b)
When set to true, all new connections will automatically have
hosting services attached to them by calling startHostingOnConnection().
|
abstract void |
startHostingOnConnection(HostedConnection hc)
Performs implementation specific connection hosting setup.
|
abstract void |
stopHostingOnConnection(HostedConnection hc)
Performs implementation specific connection tear-down.
|
getServer
getService, getServiceManager, initialize, onInitialize, start, stop, terminate, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
initialize, start, stop, terminate
protected AbstractHostedConnectionService()
protected AbstractHostedConnectionService(boolean autoHost)
public void setAutoHost(boolean b)
Reasons for doing this vary but usually would be because the client shouldn't be allowed to perform any service-related calls until it has provided more information... for example, logging in.
public boolean getAutoHost()
public abstract void startHostingOnConnection(HostedConnection hc)
public abstract void stopHostingOnConnection(HostedConnection hc)
public void connectionAdded(Server server, HostedConnection hc)
connectionAdded
in interface ConnectionListener
connectionAdded
in class AbstractHostedService
public void connectionRemoved(Server server, HostedConnection hc)
connectionRemoved
in interface ConnectionListener
connectionRemoved
in class AbstractHostedService