Class RpcConnection
java.lang.Object
com.jme3.network.service.rpc.RpcConnection
Wraps a message connection to provide RPC call support. This
is used internally by the RpcClientService and RpcHostedService to manage
network messaging.
- Author:
- Paul Speed
-
Constructor Summary
ConstructorsConstructorDescriptionRpcConnection(MessageConnection connection) Creates a new RpcConnection for the specified network connection. -
Method Summary
Modifier and TypeMethodDescriptioncallAndWait(byte channel, short objId, short procId, Object... args) Performs a remote procedure call with the specified arguments and waits for the response.voidPerforms a remote procedure call with the specified arguments but does not wait for a response.voidclose()Clears any pending synchronous calls causing them to throw an exception with the message "Closing connection".voidCalled internally when an RpcCallMessage is received from the remote connection.voidCalled internally when an RpcResponseMessage is received from the remote connection.voidregisterHandler(short objId, RpcHandler handler) Register a handler that can be called by the other end of the connection using the specified object ID.voidremoveHandler(short objId, RpcHandler handler) Removes a previously registered handler for the specified object ID.protected voidsend(byte channel, RpcResponseMessage msg) Sends an RPC response on the specified channel.
-
Constructor Details
-
RpcConnection
Creates a new RpcConnection for the specified network connection.- Parameters:
connection- the backing message connection
-
-
Method Details
-
close
public void close()Clears any pending synchronous calls causing them to throw an exception with the message "Closing connection". -
callAndWait
Performs a remote procedure call with the specified arguments and waits for the response. Both the outbound message and inbound response will be sent on the specified channel.- Parameters:
channel- the channel to useobjId- the target object idprocId- the target procedure idargs- the invocation arguments- Returns:
- the invocation result
-
callAsync
Performs a remote procedure call with the specified arguments but does not wait for a response. The outbound message is sent on the specified channel. There is no inbound response message.- Parameters:
channel- the channel to useobjId- the target object idprocId- the target procedure idargs- the invocation arguments
-
registerHandler
Register a handler that can be called by the other end of the connection using the specified object ID. Only one handler per object ID can be registered at any given time, though the same handler can be registered for multiple object IDs.- Parameters:
objId- the target object idhandler- the handler to register
-
removeHandler
Removes a previously registered handler for the specified object ID.- Parameters:
objId- the target object idhandler- the handler to remove
-
send
Sends an RPC response on the specified channel.- Parameters:
channel- the channel to usemsg- the response message
-
handleMessage
Called internally when an RpcCallMessage is received from the remote connection.- Parameters:
msg- the received RPC call
-
handleMessage
Called internally when an RpcResponseMessage is received from the remote connection.- Parameters:
msg- the received RPC response
-