Search in sources :

Example 1 with RpcCallMessage

use of com.jme3.network.service.rpc.msg.RpcCallMessage in project jmonkeyengine by jMonkeyEngine.

the class RpcConnection method 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.
     */
public Object callAndWait(byte channel, short objId, short procId, Object... args) {
    RpcCallMessage msg = new RpcCallMessage(sequenceNumber.getAndIncrement(), channel, objId, procId, args);
    // Need to register an object so we can wait for the response.
    // ...before we send it.  Just in case.
    ResponseHolder holder = new ResponseHolder(msg);
    responses.put(msg.getMessageId(), holder);
    if (log.isLoggable(Level.FINEST)) {
        log.log(Level.FINEST, "Sending:{0}  on channel:{1}", new Object[] { msg, channel });
    }
    // so it doesn't do the check.
    if (channel >= 0) {
        connection.send(channel, msg);
    } else {
        connection.send(msg);
    }
    return holder.getResponse();
}
Also used : RpcCallMessage(com.jme3.network.service.rpc.msg.RpcCallMessage)

Example 2 with RpcCallMessage

use of com.jme3.network.service.rpc.msg.RpcCallMessage in project jmonkeyengine by jMonkeyEngine.

the class RpcConnection method 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. 
     */
public void callAsync(byte channel, short objId, short procId, Object... args) {
    RpcCallMessage msg = new RpcCallMessage(-1, channel, objId, procId, args);
    if (log.isLoggable(Level.FINEST)) {
        log.log(Level.FINEST, "Sending:{0}  on channel:{1}", new Object[] { msg, channel });
    }
    connection.send(channel, msg);
}
Also used : RpcCallMessage(com.jme3.network.service.rpc.msg.RpcCallMessage)

Aggregations

RpcCallMessage (com.jme3.network.service.rpc.msg.RpcCallMessage)2