Using methodId directly without method signature; placing sendReturnObj in individual...
[iot2.git] / iotjava / iotrmi / Java / IoTRMICall.java
index 2ec265c5409edd171e65eca8809e94c832a45017..842547df8f5ff1b3ca956026b00bfc5d599ed43e 100644 (file)
@@ -31,28 +31,27 @@ public class IoTRMICall {
         */
        private IoTRMIUtil rmiUtil;
        private IoTSocketClient rmiClient;
-       private List<String> listMethodId;      // Map from method ID to signature
+       //private List<String> listMethodId;    // Map from method ID to signature
 
 
        /**
         * Constructors
         */
-       public IoTRMICall(int _port, String _address, int _rev, String[] _methodSign) throws IOException {
+       public IoTRMICall(int _port, String _address, int _rev) throws IOException {
 
                rmiUtil = new IoTRMIUtil();
                rmiClient = new IoTSocketClient(_port, _address, _rev);
-               listMethodId = Arrays.asList(_methodSign); // Initialize the method ID map
        }
 
 
        /**
         * remoteCall() calls a method remotely by passing in parameters and getting a return Object
         */
-       public synchronized Object remoteCall(int objectId, String methodSign, Class<?> retType, Class<?> retGenTypeKey, 
+       public synchronized Object remoteCall(int objectId, int methodId, Class<?> retType, Class<?> retGenTypeKey, 
                        Class<?> retGenTypeVal, Class<?>[] paramCls, Object[] paramObj) {
 
                // Send method info
-               byte[] methodBytes = methodToBytes(objectId, methodSign, paramCls, paramObj);
+               byte[] methodBytes = methodToBytes(objectId, methodId, paramCls, paramObj);
                try {
                        rmiClient.sendBytes(methodBytes);
                } catch (IOException ex) {
@@ -69,6 +68,7 @@ public class IoTRMICall {
                                ex.printStackTrace();
                                throw new Error("IoTRMICall: Error when receiving bytes - rmiClient.receiveBytes()");
                        }
+                       System.out.println("Return object bytes: " + Arrays.toString(retObjBytes));
                        retObj = IoTRMIUtil.getParamObject(retType, retGenTypeKey, retGenTypeVal, retObjBytes);
                }
                return retObj;
@@ -78,13 +78,12 @@ public class IoTRMICall {
        /**
         * methodToBytes() returns byte representation of a method
         */
-       public byte[] methodToBytes(int objectId, String methodSign, Class<?>[] paramCls, Object[] paramObj) {
+       public byte[] methodToBytes(int objectId, int methId, Class<?>[] paramCls, Object[] paramObj) {
 
                // Initialized to the length of method ID
                int methodLen = IoTRMIUtil.OBJECT_ID_LEN;
                byte[] objId = IoTRMIUtil.intToByteArray(objectId);
                // Get method ID in bytes
-               int methId = listMethodId.indexOf(methodSign);
                byte[] methodId = IoTRMIUtil.intToByteArray(methId);
                // Get byte arrays and calculate method bytes length
                int numbParam = paramObj.length;