git-svn-id: svn://elaine/murooma/trunk@257 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-09-13 20:42:45 +00:00
parent 3369363453
commit 6d6272d23a
5 changed files with 44 additions and 8 deletions

View file

@ -1,4 +1,5 @@
#include "controlServer.h"
#include "common/timeMsg.h"
#include <iostream>
@ -9,7 +10,16 @@ ControlServer::ControlServer(unsigned short port) : port_(port), headerChunk(NUL
void ControlServer::onMessageReceived(SocketConnection* connection, const BaseMessage& baseMessage, char* buffer)
{
cout << "onMessageReceived: " << baseMessage.type << ", " << baseMessage.size << "\n";
cout << "onMessageReceived: " << baseMessage.type << ", size: " << baseMessage.size << ", sent: " << baseMessage.sent.sec << "," << baseMessage.sent.usec << ", recv: " << baseMessage.received.sec << "," << baseMessage.received.usec << "\n";
if (baseMessage.type == message_type::timemsg)
{
TimeMsg* timeMsg = new TimeMsg();
timeMsg->deserialize(baseMessage, buffer);
timeMsg->latency = (timeMsg->received.sec - timeMsg->sent.sec) * 1000000 + (timeMsg->received.usec - timeMsg->sent.usec);
cout << "Latency: " << timeMsg->latency << "\n";
timeMsg->refersTo = timeMsg->id;
connection->send(timeMsg);
}
}