3 #include "TestClassComplete_Stub.hpp"
4 #include "CallBack.hpp"
6 #include "CallBackInterface_Skeleton.cpp"
11 TestClassComplete_Stub::TestClassComplete_Stub(int _port, const char* _skeletonAddress, string _callbackAddress, int _rev, bool* _bResult, vector<int> _ports) {
12 callbackAddress = _callbackAddress;
14 rmiCall = new IoTRMICall(_port, _skeletonAddress, _rev, _bResult);
15 set0Allowed.insert(-9998);
16 //thread th1 (&TestClassComplete_Stub::___initCallBack, this);
21 TestClassComplete_Stub::TestClassComplete_Stub(IoTRMICall* _rmiCall, string _callbackAddress, int _objIdCnt, vector<int> _ports) {
22 callbackAddress = _callbackAddress;
25 set0Allowed.insert(-9998);
26 //thread th1 (&TestClassComplete_Stub::___initCallBack, this);
31 TestClassComplete_Stub::~TestClassComplete_Stub() {
32 if (rmiCall != NULL) {
40 for(CallBackInterface* cb : vecCallbackObj) {
46 void TestClassComplete_Stub::registerCallback(CallBackInterface* _cb) {
47 //CallBackInterface_CallbackSkeleton* skel0 = new CallBackInterface_CallbackSkeleton(_cb, callbackAddress, objIdCnt++);
48 CallBackInterface_Skeleton* skel0 = new CallBackInterface_Skeleton(_cb, callbackAddress, objIdCnt++);
49 vecCallbackObj.push_back(skel0);
52 string retType = "void";
54 string paramCls[] = { "int" };
55 void* paramObj[] = { &___paramCB0 };
57 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
60 void TestClassComplete_Stub::___regCB() {
63 string retType = "void";
64 string paramCls[] = { "int*", "String", "int" };
66 void* paramObj[] = { &ports, &callbackAddress, &rev };
68 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
71 short TestClassComplete_Stub::getShort(short in) {
73 string retType = "short";
75 string paramCls[] = { "short" };
76 void* paramObj[] = { &in };
78 void* retObj = &retVal;
79 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
83 int TestClassComplete_Stub::callBack() {
85 string retType = "int";
87 string paramCls[] = { };
88 void* paramObj[] = { };
90 void* retObj = &retVal;
91 rmiCall->remoteCall(objectId, methodId, retType, paramCls, paramObj, numParam, retObj);
96 int main(int argc, char *argv[])
100 const char* address = "localhost";
101 //const char* address = "192.168.2.191"; // RPi2
102 //const char* skeletonAddress = "128.195.136.170"; // dc-9.calit2.uci.edu
103 const char* skeletonAddress = "128.195.204.132";
104 const char* callbackAddress = "128.195.204.132"; // dw-2.eecs.uci.edu (this machine)
105 //const char* skeletonAddress = "192.168.2.108"; // RPi1
106 //const char* callbackAddress = "192.168.2.191"; // RPi2
108 bool bResult = false;
110 ports.push_back(12345);
111 ports.push_back(22346);
112 //ports.push_back(32344);
113 //ports.push_back(43212);
115 TestClassComplete *tcStub = new TestClassComplete_Stub(port, skeletonAddress, callbackAddress, rev, &bResult, ports);
116 cout << "==== CALLBACK ====" << endl;
117 CallBackInterface *cbSingle = new CallBack(2354);
118 tcStub->registerCallback(cbSingle);
119 cout << "Return value from callback: " << tcStub->callBack() << endl;