2 #include "RoomSmart_Stub.hpp"
6 RoomSmart_Stub::RoomSmart_Stub(int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult) {
9 string file = "RoomSmart_Stub_cpp" + to_string(i) + ".log";
10 while (ifstream(file.c_str())) {
12 file = "RoomSmart_Stub_cpp" + to_string(i) + ".log";
15 log << "Send port: " << _portSend << endl;
16 log << "Recv port: " << _portRecv << endl;
17 log << "Skeleton address: " << _skeletonAddress << endl;
18 log << "Rev: " << _rev << endl;
19 log << "bResult: " << *_bResult << endl;
20 rmiComm = new IoTRMICommClient(_portSend, _portRecv, _skeletonAddress, _rev, _bResult);
21 log << "Established connection with skeleton!" << endl;
22 rmiComm->registerStub(objectId, 0, &retValueReceived0);
23 IoTRMIUtil::mapStub->insert(make_pair(objectId, this));
26 RoomSmart_Stub::RoomSmart_Stub(IoTRMIComm* _rmiComm, int _objectId) {
29 rmiComm->registerStub(objectId, 0, &retValueReceived0);
32 RoomSmart_Stub::~RoomSmart_Stub() {
33 if (rmiComm != NULL) {
39 mutex mtxRoomSmart_StubMethodExec0;
40 int RoomSmart_Stub::getRoomID() {
41 lock_guard<mutex> guard(mtxRoomSmart_StubMethodExec0);
43 string retType = "int";
45 string paramCls[] = { };
46 void* paramObj[] = { };
48 void* retObj = &retVal;
49 rmiComm->remoteCall(objectId, methodId, paramCls, paramObj, numParam);
50 // Waiting for return value
51 while (!retValueReceived0);
52 rmiComm->getReturnValue(retType, retObj);
53 retValueReceived0 = false;
54 didGetReturnBytes.exchange(true);
59 extern "C" void* createRoomSmart_Stub(void** params) {
60 // Args: int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult
61 return new RoomSmart_Stub(*((int*) params[0]), *((int*) params[1]), ((string*) params[2])->c_str(), *((int*) params[3]), (bool*) params[4]);
64 extern "C" void destroyRoomSmart_Stub(void* t) {
65 RoomSmart_Stub* obj = (RoomSmart_Stub*) t;
69 extern "C" void initRoomSmart_Stub(void* t) {
74 /*int send_port = 5010;
76 const char* skeletonAddress = "localhost";
77 //const char* skeletonAddress = "l92.168.1.198";
78 //const char* skeletonAddress = "127.0.0.1";
82 RoomSmart_Stub *rm = new RoomSmart_Stub(send_port, recv_port, skeletonAddress, rev, &result);
83 cout << "Successfully instantiated stub!" << endl;*/