using namespace std;
-class IoTRMICommServer : public IoTRMIComm {
+class IoTRMICommServer final : public IoTRMIComm {
public:
IoTRMICommServer(int _portSend, int _portRecv, bool* _bResult);
~IoTRMICommServer();
void IoTRMICommServer::waitForConnectionOnServerRecv() {
- cout << "Wait on connection ServerRecv!" << endl;
rmiServerRecv->connect();
- cout << "Connected on connection ServerRecv!" << endl;
}
void IoTRMICommServer::waitForConnectionOnServerSend() {
- cout << "Wait on connection ServerSend!" << endl;
rmiServerSend->connect();
- cout << "Connected on connection ServerSend!" << endl;
}
char* packetBytes = NULL;
int packetLen = 0;
- //cout << "Starting waitForPacketsOnServer()" << endl;
while(true) {
fflush(NULL);
packetBytes = rmiComm->rmiServerRecv->receiveBytes(packetBytes, &packetLen);
fflush(NULL);
if (packetBytes != NULL) { // If there is method bytes
- //IoTRMIUtil::printBytes(packetBytes, packetLen, false);
int packetType = IoTRMIComm::getPacketType(packetBytes);
if (packetType == IoTRMIUtil::METHOD_TYPE) {
rmiComm->methodQueue.enqueue(packetBytes, packetLen);
rmiComm->returnQueue.enqueue(packetBytes, packetLen);
} else {
// TODO: We need to log error message when we come to running this using IoTSlave
- // TODO: Beware that using "cout" in the process will kill it (as IoTSlave is loaded in Sentinel)
+ // TODO: Beware that using "cout" in the process will kill it (as IoTSlave is loaded at runtime)
cerr << "IoTRMICommServer: Packet type is unknown: " << packetType << endl;
exit(1);
}
IoTRMIUtil::getObjectBytes(retObjBytes, retObj, type.c_str());
memcpy(retAllObjBytes + headerLen, retObjBytes, retLen);
fflush(NULL);
- IoTRMIUtil::printBytes(retAllObjBytes, headerLen+retLen, false);
rmiServerSend->sendBytes(retAllObjBytes, headerLen+retLen);
fflush(NULL);
}