Allow remote calls to be made on the default channel

instead of just custom channels.  Custom channels are
0-max channel while -1 indicates the default send().
experimental
Paul Speed 10 years ago
parent dd65580bf3
commit 96dab5f561
  1. 23
      jme3-networking/src/main/java/com/jme3/network/service/rpc/RpcConnection.java

@ -116,7 +116,11 @@ public class RpcConnection {
if( log.isLoggable(Level.FINEST) ) {
log.log(Level.FINEST, "Sending:{0} on channel:{1}", new Object[]{msg, channel});
}
connection.send(channel, msg);
if( channel >= 0 ) {
connection.send(channel, msg);
} else {
connection.send(msg);
}
return holder.getResponse();
}
@ -159,6 +163,14 @@ public class RpcConnection {
handlers.remove(objId);
}
protected void send( byte channel, RpcResponseMessage msg ) {
if( channel >= 0 ) {
connection.send(channel, msg);
} else {
connection.send(msg);
}
}
/**
* Called internally when an RpcCallMessage is received from
* the remote connection.
@ -170,15 +182,16 @@ public class RpcConnection {
}
RpcHandler handler = handlers.get(msg.getObjectId());
try {
if( handler == null ) {
throw new RuntimeException("Handler not found for objectID:" + msg.getObjectId());
}
Object result = handler.call(this, msg.getObjectId(), msg.getProcedureId(), msg.getArguments());
if( !msg.isAsync() ) {
RpcResponseMessage response = new RpcResponseMessage(msg.getMessageId(), result);
connection.send(msg.getChannel(), response);
send(msg.getChannel(), new RpcResponseMessage(msg.getMessageId(), result));
}
} catch( Exception e ) {
if( !msg.isAsync() ) {
RpcResponseMessage response = new RpcResponseMessage(msg.getMessageId(), e);
connection.send(msg.getChannel(), response);
send(msg.getChannel(), new RpcResponseMessage(msg.getMessageId(), e));
} else {
log.log(Level.SEVERE, "Error invoking async call for:" + msg, e);
}

Loading…
Cancel
Save