Package com.jme3.network.service.rpc
Class RpcHostedService
java.lang.Object
com.jme3.network.service.AbstractService<HostedServiceManager>
com.jme3.network.service.AbstractHostedService
com.jme3.network.service.AbstractHostedConnectionService
com.jme3.network.service.rpc.RpcHostedService
- All Implemented Interfaces:
ConnectionListener
,HostedService
,Service<HostedServiceManager>
RPC service that can be added to a network Server to
add RPC send/receive capabilities. For a particular
HostedConnection, Remote procedure calls can be made to the
associated Client and responses retrieved. Any remote procedure
calls that the Client performs for this connection will be
received by this service and delegated to the appropriate RpcHandlers.
Note: it can be dangerous for a server to perform synchronous
RPC calls to a client but especially so if not done as part
of the response to some other message. ie: iterating over all
or some HostedConnections to perform synchronous RPC calls
will be slow and potentially block the server's threads in ways
that can cause deadlocks or odd contention.
-
Constructor Summary
ConstructorDescriptionCreates a new RPC host service that can be registered with the Network server and will automatically 'host' RPC services and each new network connection.RpcHostedService
(boolean autoHost) Creates a new RPC host service that can be registered with the Network server and will optionally 'host' RPC services and each new network connection depending on the specified 'autoHost' flag. -
Method Summary
Modifier and TypeMethodDescriptionRetrieves the RpcConnection for the specified HostedConnection if that HostedConnection has had RPC services started using startHostingOnConnection() (or via autohosting).protected void
onInitialize
(HostedServiceManager serviceManager) Used internally to set up the message delegator that will handle HostedConnection specific messages and forward them to that connection's RpcConnection.void
Sets up RPC hosting services for the hosted connection allowing getRpcConnection() to return a valid RPC connection object.void
Removes any RPC hosting services associated with the specified connection.void
terminate
(HostedServiceManager serviceManager) Used internally to remove the message delegator from the server.Methods inherited from class com.jme3.network.service.AbstractHostedConnectionService
connectionAdded, connectionRemoved, getAutoHost, setAutoHost
Methods inherited from class com.jme3.network.service.AbstractHostedService
getServer
Methods inherited from class com.jme3.network.service.AbstractService
getService, getServiceManager, initialize, start, stop, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface com.jme3.network.service.HostedService
initialize, start, stop
-
Constructor Details
-
RpcHostedService
public RpcHostedService()Creates a new RPC host service that can be registered with the Network server and will automatically 'host' RPC services and each new network connection. -
RpcHostedService
public RpcHostedService(boolean autoHost) Creates a new RPC host service that can be registered with the Network server and will optionally 'host' RPC services and each new network connection depending on the specified 'autoHost' flag.
-
-
Method Details
-
onInitialize
Used internally to set up the message delegator that will handle HostedConnection specific messages and forward them to that connection's RpcConnection.- Specified by:
onInitialize
in classAbstractService<HostedServiceManager>
-
getRpcConnection
Retrieves the RpcConnection for the specified HostedConnection if that HostedConnection has had RPC services started using startHostingOnConnection() (or via autohosting). Returns null if the connection currently doesn't have RPC hosting services attached. -
startHostingOnConnection
Sets up RPC hosting services for the hosted connection allowing getRpcConnection() to return a valid RPC connection object. This method is called automatically for all new connections if autohost is set to true.- Specified by:
startHostingOnConnection
in classAbstractHostedConnectionService
-
stopHostingOnConnection
Removes any RPC hosting services associated with the specified connection. Calls to getRpcConnection() will return null for this connection. The connection's RpcConnection is also closed, releasing any waiting synchronous calls with a "Connection closing" error. This method is called automatically for all leaving connections if autohost is set to true.- Specified by:
stopHostingOnConnection
in classAbstractHostedConnectionService
-
terminate
Used internally to remove the message delegator from the server.- Specified by:
terminate
in interfaceHostedService
- Specified by:
terminate
in interfaceService<HostedServiceManager>
- Overrides:
terminate
in classAbstractService<HostedServiceManager>
-