Fixed compiler for Java code generation (not heavily tested yet, but fixes include...
[iot2.git] / iotjava / iotrmi / C++ / IoTRMIObject.hpp
index 27931cbd0b0d78f51dff057edfc4c27d8e744db4..1dd3d57ba10b91c3c3a0d77d38dbd753eb9b95ea 100644 (file)
@@ -35,6 +35,7 @@ class IoTRMIObject {
                int                                     getObjectId();
                static int                      getObjectId(char* methodBytes);
                int                                     getMethodId();
+               static int                      getMethodId(char* methodBytes);
                void**                          getMethodParams(string paramCls[], int numParam, void* paramObj[]);
 
        private:
@@ -112,7 +113,6 @@ void IoTRMIObject::sendReturnObj(void* retObj[], string type[], int numRet) {
        // Need object bytes variable
        char retObjBytes[retLen];
        returnToBytes(retObj, type, retObjBytes, numRet);
-       IoTRMIUtil::printBytes(retObjBytes, retLen, false);
        rmiServer->sendBytes(retObjBytes, retLen);
 }
 
@@ -121,7 +121,7 @@ void IoTRMIObject::sendReturnObj(void* retObj[], string type[], int numRet) {
 char* IoTRMIObject::getMethodBytes() {
 
        // Get method in bytes and update method length
-       //fflush(NULL);
+       fflush(NULL);
        methodBytes = rmiServer->receiveBytes(methodBytes, &methodLen);
        fflush(NULL);
        return methodBytes;
@@ -175,6 +175,20 @@ int IoTRMIObject::getMethodId() {
 }
 
 
+// Get methodId from bytes (static version)
+int IoTRMIObject::getMethodId(char* methodBytes) {
+
+       // Get method Id
+       char methodIdBytes[IoTRMIUtil::METHOD_ID_LEN];
+       memcpy(methodIdBytes, methodBytes + IoTRMIUtil::OBJECT_ID_LEN, IoTRMIUtil::METHOD_ID_LEN);
+       // Get method signature 
+       int methodId = 0;
+       IoTRMIUtil::byteArrayToInt(&methodId, methodIdBytes);
+       
+       return methodId;
+}
+
+
 // Get method parameters and return an array of parameter objects
 //
 // For primitive objects: