*/
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) {
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;
/**
* 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;