Class RpcClientService

All Implemented Interfaces:
ClientService, Service<ClientServiceManager>

public class RpcClientService extends AbstractClientService
RPC service that can be added to a network Client to add RPC send/receive capabilities. Remote procedure calls can be made to the server and responses retrieved. Any remote procedure calls that the server performs for this connection will be received by this service and delegated to the appropriate RpcHandlers.
  • Constructor Details

    • RpcClientService

      public RpcClientService()
      Creates a new RpcClientService that can be registered with the network Client object.
  • Method Details

    • getRpcConnection

      public RpcConnection getRpcConnection()
      Returns the underlying RPC connection for use by other services that may require a more generic non-client/server specific RPC object with which to interact.
    • onInitialize

      protected void onInitialize(ClientServiceManager serviceManager)
      Used internally to set up the RpcConnection and MessageDelegator.
      Specified by:
      onInitialize in class AbstractService<ClientServiceManager>
    • terminate

      public void terminate(ClientServiceManager serviceManager)
      Used internally to unregister the RPC MessageDelegator that was previously added to the network Client.
      Specified by:
      terminate in interface ClientService
      Specified by:
      terminate in interface Service<ClientServiceManager>
      Overrides:
      terminate in class AbstractService<ClientServiceManager>
    • callAndWait

      public Object callAndWait(byte channel, short objId, short procId, Object... args)
      Performs a synchronous call on the server against the specified object using the specified procedure ID. Both inbound and outbound communication is done on the specified channel.
    • callAsync

      public void callAsync(byte channel, short objId, short procId, Object... args)
      Performs an asynchronous call on the server against the specified object using the specified procedure ID. Communication is done over the specified channel. No responses are received and none are waited for.
    • registerHandler

      public void registerHandler(short objId, RpcHandler handler)
      Register a handler that will be called when the server performs a remove procedure call against this client. Only one handler per object ID can be registered at any given time, though the same handler can be registered for multiple object IDs.
    • removeHandler

      public void removeHandler(short objId, RpcHandler handler)
      Removes a previously registered handler for the specified object ID.