1 #ifndef _CALLBACK_SKELETON_HPP__
2 #define _CALLBACK_SKELETON_HPP__
5 #include "../IoTRMIObject.hpp"
6 #include "CallBack.hpp"
10 class CallBack_Skeleton : public CallBackInterface {
12 CallBack_Skeleton(CallBackInterface* _cb, int _port);
15 void waitRequestInvokeMethod();
19 const static int size = 2;
20 const static string methodSignatures[size];
23 CallBackInterface *cb;
28 const string CallBack_Skeleton::methodSignatures[CallBack_Skeleton::size] = {
36 CallBack_Skeleton::CallBack_Skeleton(CallBackInterface* _cb, int _port) {
38 bool _bResult = false;
40 rmiObj = new IoTRMIObject(_port, &_bResult, methodSignatures, size);
41 waitRequestInvokeMethod();
45 CallBack_Skeleton::~CallBack_Skeleton() {
54 void CallBack_Skeleton::waitRequestInvokeMethod() {
56 // Loop continuously waiting for incoming bytes
59 rmiObj->getMethodBytes();
60 string methodSign = rmiObj->getSignature();
61 cout << "Method sign: " << methodSign << endl;
63 if (methodSign.compare("intprintInt()") == 0) {
64 string paramCls[] = { };
66 void* paramObj[] = { };
67 rmiObj->getMethodParams(paramCls, numParam, paramObj);
68 int retVal = printInt();
69 void* retObj = &retVal;
70 rmiObj->sendReturnObj(retObj, "int");
71 } else if (methodSign.compare("voidsetInt(int)") == 0) {
72 string paramCls[] = { "int" };
75 void* paramObj[] = { ¶m1 };
76 rmiObj->getMethodParams(paramCls, numParam, paramObj);
79 string error = "Signature not recognized: " + string(methodSign);
86 int CallBack_Skeleton::printInt() {
88 return cb->printInt();
92 void CallBack_Skeleton::setInt(int _i) {