#ifndef _ROOMSMART_STUB_HPP__
#define _ROOMSMART_STUB_HPP__
#include <iostream>
-#include <fstream>
+#include <thread>
+#include <mutex>
+#include <vector>
+#include <set>
+#include "IoTRMIComm.hpp"
+#include "IoTRMICommClient.hpp"
+#include "IoTRMICommServer.hpp"
+
#include "RoomSmart.hpp"
+#include <fstream>
using namespace std;
{
private:
- IoTRMICall *rmiCall;
- string callbackAddress;
- vector<int> ports;
-
- const static int objectId = 0;
-
+ IoTRMIComm *rmiComm;
+ int objectId = 4;
+ // Synchronization variables
+ bool retValueReceived0 = false;
ofstream log;
- public:
-
- RoomSmart_Stub() { }
-
- RoomSmart_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
- callbackAddress = _callbackAddress;
- ports = _ports;
- // Logging
- log.open("RoomSmart_Stub_cpp.log");
- log << "Port: " << _port << endl;
- log << "Skeleton address: " << _skeletonAddress << endl;
- log << "Callback address: " << callbackAddress << endl;
- log << "Rev: " << _rev << endl;
- log << "bResult: " << *_bResult << endl;
- log << "Ports: " << _ports[0] << endl;
- rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
- log << "Established connection with skeleton!" << endl;
- }
- ~RoomSmart_Stub() {
- if (rmiCall != NULL) {
- delete rmiCall;
- rmiCall = NULL;
- }
- }
-
- int getRoomID() {
- log << "Calling getRoomID() in stub!" << endl;
- int methodId = 0;
- string retType = "int";
- int numParam = 0;
- string paramCls[] = { };
- void* paramObj[] = { };
- int retVal = 0;
- void* retObj = &retVal;
- log << "About to remote call!" << endl;
- rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
- log << "Remote call performed!" << endl;
- return retVal;
- }
+ public:
+ RoomSmart_Stub();
+ RoomSmart_Stub(int _portSend, int _portRecv, const char* _skeletonAddress, int _rev, bool* _bResult);
+ RoomSmart_Stub(IoTRMIComm* _rmiComm, int _objectId);
+ ~RoomSmart_Stub();
+ int getRoomID();
};
#endif