#ifndef _LIGHTBULB_SKELETON_HPP__
#define _LIGHTBULB_SKELETON_HPP__
#include <iostream>
+#include <fstream>
#include "LightBulb.hpp"
#include <vector>
const static int object0Id = 0; //LightBulbSmart
static set<int> set0Allowed;
-
+ ofstream log;
public:
LightBulb_Skeleton(LightBulb *_mainObj, string _callbackAddress, int _port) {
bool _bResult = false;
mainObj = _mainObj;
callbackAddress = _callbackAddress;
+ // Logging
+ log.open("LightBulb_Skeleton_cpp.log");
+ log << "Callback address: " << callbackAddress << endl;
+ log << "Port: " << _port << endl;
rmiObj = new IoTRMIObject(_port, &_bResult);
+ log << "Established connection with slave! Wait request invoke now..." << endl;
___waitRequestInvokeMethod();
}
void ___waitRequestInvokeMethod() {
while (true) {
+ log << "Getting into the while loop" << endl;
rmiObj->getMethodBytes();
+ log << "Getting method bytes now" << endl;
+ log << "Method len: " << rmiObj->getMethodBytesLen() << endl;
int _objectId = rmiObj->getObjectId();
+ log << "Object Id: " << _objectId << endl;
int methodId = rmiObj->getMethodId();
+ log << "Method Id: " << methodId << endl;
if (_objectId == object0Id) {
if (set0Allowed.find(methodId) == set0Allowed.end()) {
cerr << "Object with object Id: " << _objectId << " is not allowed to access method: " << methodId << endl;
throw exception();
}
}
+ log.close();
}
};
set<int> LightBulb_Skeleton::set0Allowed { 2, 10, 1, 3, 11, 8, 12, 7, 13, 9, 6, 16, 17, 4, 0, 14, 15, 5 };
-//typedef LightBulb_Skeleton* create_t(LightBulb *_mainObj, string _callbackAddress, int _port);
-//typedef void destroy_t(LightBulb_Skeleton*);
#endif