From 96dab5f5617ba544d05bf3a6e9c0d983a61afb12 Mon Sep 17 00:00:00 2001 From: Paul Speed Date: Sun, 26 Apr 2015 02:28:38 -0400 Subject: [PATCH] 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(). --- .../network/service/rpc/RpcConnection.java | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/jme3-networking/src/main/java/com/jme3/network/service/rpc/RpcConnection.java b/jme3-networking/src/main/java/com/jme3/network/service/rpc/RpcConnection.java index b5e66c188..b78316bf3 100644 --- a/jme3-networking/src/main/java/com/jme3/network/service/rpc/RpcConnection.java +++ b/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); }