Package com.jme3.network.service
Class AbstractHostedConnectionService
java.lang.Object
com.jme3.network.service.AbstractService<HostedServiceManager>
com.jme3.network.service.AbstractHostedService
com.jme3.network.service.AbstractHostedConnectionService
- All Implemented Interfaces:
- ConnectionListener,- HostedService,- Service<HostedServiceManager>
- Direct Known Subclasses:
- RpcHostedService
Convenient base class for HostedServices providing some default HostedService 
  interface implementations as well as a few convenience methods 
  such as getServiceManager() and getService(type).  This implementation
  enhances the default capabilities provided by AbstractHostedService by
  adding automatic connection management.
 
  
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 autoHost is false then it is up to the implementation or application to specifically start hosting at some point.
- 
Constructor SummaryConstructorsModifierConstructorDescriptionprotectedCreates a new HostedService that will autohost connections when detected.protectedAbstractHostedConnectionService(boolean autoHost) Creates a new HostedService that will automatically host connections only if autoHost is true.
- 
Method SummaryModifier and TypeMethodDescriptionvoidconnectionAdded(Server server, HostedConnection hc) Called internally when a new connection is detected for the server.voidconnectionRemoved(Server server, HostedConnection hc) Called internally when an existing connection is leaving the server.booleanReturns true if this service automatically attaches hosting capabilities to new connections.voidsetAutoHost(boolean b) When set to true, all new connections will automatically have hosting services attached to them by calling startHostingOnConnection().abstract voidPerforms implementation specific connection hosting setup.abstract voidPerforms implementation specific connection tear-down.Methods inherited from class com.jme3.network.service.AbstractHostedServicegetServerMethods inherited from class com.jme3.network.service.AbstractServicegetService, getServiceManager, initialize, onInitialize, start, stop, terminate, toStringMethods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface com.jme3.network.service.HostedServiceinitialize, start, stop, terminate
- 
Constructor Details- 
AbstractHostedConnectionServiceprotected AbstractHostedConnectionService()Creates a new HostedService that will autohost connections when detected.
- 
AbstractHostedConnectionServiceprotected AbstractHostedConnectionService(boolean autoHost) Creates a new HostedService that will automatically host connections only if autoHost is true.
 
- 
- 
Method Details- 
setAutoHostpublic void setAutoHost(boolean b) When set to true, all new connections will automatically have hosting services attached to them by calling startHostingOnConnection(). If this is set to false then it is up to the application or other services to eventually call startHostingOnConnection().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. 
- 
getAutoHostpublic boolean getAutoHost()Returns true if this service automatically attaches hosting capabilities to new connections.
- 
startHostingOnConnectionPerforms implementation specific connection hosting setup. Generally this involves setting up some handlers or session attributes on the connection. If autoHost is true then this method is called automatically during connectionAdded() processing.
- 
stopHostingOnConnectionPerforms implementation specific connection tear-down. This will be called automatically when the connectionRemoved() event occurs... whether the application has already called it or not.
- 
connectionAddedCalled internally when a new connection is detected for the server. If the current autoHost property is true then startHostingOnConnection(hc) is called.- Specified by:
- connectionAddedin interface- ConnectionListener
- Overrides:
- connectionAddedin class- AbstractHostedService
 
- 
connectionRemovedCalled internally when an existing connection is leaving the server. This method always calls stopHostingOnConnection(hc). Implementations should be aware that if they stopHostingOnConnection() early that they will get a second call when the connection goes away.- Specified by:
- connectionRemovedin interface- ConnectionListener
- Overrides:
- connectionRemovedin class- AbstractHostedService
 
 
-