#define _TESTCLASS_STUB_HPP__
#include <iostream>
+#include <set>
#include <thread>
#include "../IoTRMICall.hpp"
#include "../IoTRMIObject.hpp"
void ____init_CallBack(); // thread
void ____registerCallBack(); // tell the other side that we are ready
+ //exception_ptr teptr = nullptr;
+
private:
int intA;
float floatB;
IoTRMIObject *rmiObj;
vector<CallBackInterface*> vecCBObj;
static int objIdCnt;
+ // Callback permission
+ const static set<int> set0Allowed;
};
int TestClass_Stub::objIdCnt = 0;
+const set<int> TestClass_Stub::set0Allowed { 0, 1 };
+
+
TestClass_Stub::TestClass_Stub() {
address = "";
rmiCall = new IoTRMICall(_port, _address, _rev, _bResult);
ports = _ports;
// Start thread
-// thread th1 (&TestClass_Stub::____init_CallBack, this);
-// th1.detach();
+ /*if (teptr) {
+ try {
+ thread th1 (&TestClass_Stub::____init_CallBack, this);
+ th1.detach();
+ } catch(const exception&) {
+ cout << "Got here!" << endl;
+ throw exception();
+ }
+ }*/
+ thread th1 (&TestClass_Stub::____init_CallBack, this);
+ th1.detach();
//th1.join();
-// ____registerCallBack();
+ ____registerCallBack();
}
rmiObj = new IoTRMIObject(ports[0], &bResult);
while (true) {
char* method = rmiObj->getMethodBytes();
+ int methodId = IoTRMIObject::getMethodId(method);
+ // Permission check
+ // Complain if the method is not allowed
+ if (set0Allowed.find(methodId) == set0Allowed.end()) {
+ cerr << "TestClass_Skeleton: This object is not allowed to access method " << methodId << endl;
+ exit(-1);
+ //throw exception();
+ //teptr = current_exception();
+ }
int objId = IoTRMIObject::getObjectId(method);
if (objId < vecCBObj.size()) { // Check if still within range
CallBack_CBSkeleton* skel =