mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 13:04:07 +02:00
Merge pull request #593 from LionTurtle/master
ping reporter added to interface
This commit is contained in:
commit
eedaf5f76e
7 changed files with 62 additions and 2 deletions
|
@ -391,6 +391,10 @@ int main(int argc, const char* argv[]) {
|
||||||
|
|
||||||
// give the new audio data to the matching injector agent
|
// give the new audio data to the matching injector agent
|
||||||
agentList->updateAgentWithData(matchingInjector, packetData, receivedBytes);
|
agentList->updateAgentWithData(matchingInjector, packetData, receivedBytes);
|
||||||
|
} else if (packetData[0] == PACKET_HEADER_PING) {
|
||||||
|
|
||||||
|
// If the packet is a ping, let processAgentData handle it.
|
||||||
|
agentList->processAgentData(agentAddress, packetData, receivedBytes);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -833,9 +833,23 @@ void Application::wheelEvent(QWheelEvent* event) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void sendPingPackets() {
|
||||||
|
|
||||||
|
char agentTypesOfInterest[] = {AGENT_TYPE_VOXEL_SERVER, AGENT_TYPE_AUDIO_MIXER, AGENT_TYPE_AVATAR_MIXER};
|
||||||
|
long long currentTime = usecTimestampNow();
|
||||||
|
char pingPacket[1 + sizeof(currentTime)];
|
||||||
|
pingPacket[0] = PACKET_HEADER_PING;
|
||||||
|
|
||||||
|
memcpy(&pingPacket[1], ¤tTime, sizeof(currentTime));
|
||||||
|
AgentList::getInstance()->broadcastToAgents((unsigned char*)pingPacket, 1 + sizeof(currentTime), agentTypesOfInterest, 3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// Every second, check the frame rates and other stuff
|
// Every second, check the frame rates and other stuff
|
||||||
void Application::timer() {
|
void Application::timer() {
|
||||||
gettimeofday(&_timerEnd, NULL);
|
gettimeofday(&_timerEnd, NULL);
|
||||||
|
sendPingPackets();
|
||||||
|
|
||||||
_fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
_fps = (float)_frameCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
||||||
_packetsPerSecond = (float)_packetCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
_packetsPerSecond = (float)_packetCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
||||||
_bytesPerSecond = (float)_bytesCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
_bytesPerSecond = (float)_bytesCount / ((float)diffclock(&_timerStart, &_timerEnd) / 1000.f);
|
||||||
|
@ -2280,6 +2294,24 @@ void Application::displayStats() {
|
||||||
_fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f);
|
_fps, _packetsPerSecond, (float)_bytesPerSecond * 8.f / 1000000.f);
|
||||||
drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);
|
drawtext(10, statsVerticalOffset + 15, 0.10f, 0, 1.0, 0, stats);
|
||||||
|
|
||||||
|
int pingAudio = 0, pingAvatar = 0, pingVoxel = 0;
|
||||||
|
|
||||||
|
AgentList *agentList = AgentList::getInstance();
|
||||||
|
Agent *audioMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AUDIO_MIXER);
|
||||||
|
Agent *avatarMixerAgent = agentList->soloAgentOfType(AGENT_TYPE_AVATAR);
|
||||||
|
Agent *voxelServerAgent = agentList->soloAgentOfType(AGENT_TYPE_VOXEL_SERVER);
|
||||||
|
|
||||||
|
if (audioMixerAgent != NULL)
|
||||||
|
pingAudio = audioMixerAgent->getPingMs();
|
||||||
|
if (avatarMixerAgent != NULL)
|
||||||
|
pingAvatar = avatarMixerAgent->getPingMs();
|
||||||
|
if (voxelServerAgent != NULL)
|
||||||
|
pingVoxel = voxelServerAgent->getPingMs();
|
||||||
|
|
||||||
|
char pingStats[200];
|
||||||
|
sprintf(pingStats, "Ping audio/avatar/voxel: %d / %d / %d ", pingAudio, pingAvatar, pingVoxel);
|
||||||
|
drawtext(10, statsVerticalOffset + 35, 0.10f, 0, 1.0, 0, pingStats);
|
||||||
|
|
||||||
std::stringstream voxelStats;
|
std::stringstream voxelStats;
|
||||||
voxelStats.precision(4);
|
voxelStats.precision(4);
|
||||||
voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K";
|
voxelStats << "Voxels Rendered: " << _voxels.getVoxelsRendered() / 1000.f << "K Updated: " << _voxels.getVoxelsUpdated()/1000.f << "K";
|
||||||
|
|
|
@ -335,6 +335,7 @@ private:
|
||||||
int _packetsPerSecond;
|
int _packetsPerSecond;
|
||||||
int _bytesPerSecond;
|
int _bytesPerSecond;
|
||||||
int _bytesCount;
|
int _bytesCount;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__interface__Application__) */
|
#endif /* defined(__interface__Application__) */
|
||||||
|
|
|
@ -63,6 +63,9 @@ public:
|
||||||
float getAverageKilobitsPerSecond();
|
float getAverageKilobitsPerSecond();
|
||||||
float getAveragePacketsPerSecond();
|
float getAveragePacketsPerSecond();
|
||||||
|
|
||||||
|
int getPingMs() const { return _pingMs; };
|
||||||
|
void setPingMs(int pingMs) { _pingMs = pingMs; };
|
||||||
|
|
||||||
static void printLog(Agent const&);
|
static void printLog(Agent const&);
|
||||||
private:
|
private:
|
||||||
// privatize copy and assignment operator to disallow Agent copying
|
// privatize copy and assignment operator to disallow Agent copying
|
||||||
|
@ -79,6 +82,7 @@ private:
|
||||||
SimpleMovingAverage* _bytesReceivedMovingAverage;
|
SimpleMovingAverage* _bytesReceivedMovingAverage;
|
||||||
AgentData* _linkedData;
|
AgentData* _linkedData;
|
||||||
bool _isAlive;
|
bool _isAlive;
|
||||||
|
int _pingMs;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,17 @@ AgentList::~AgentList() {
|
||||||
pthread_mutex_destroy(&mutex);
|
pthread_mutex_destroy(&mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AgentList::timePingReply(sockaddr *agentAddress, unsigned char *packetData) {
|
||||||
|
for(AgentList::iterator agent = begin(); agent != end(); agent++) {
|
||||||
|
if (socketMatch(agent->getPublicSocket(), agentAddress) ||
|
||||||
|
socketMatch(agent->getLocalSocket(), agentAddress)) {
|
||||||
|
int pingTime = usecTimestampNow() - *(long long *)(packetData + 1);
|
||||||
|
agent->setPingMs(pingTime / 1000);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void AgentList::processAgentData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes) {
|
void AgentList::processAgentData(sockaddr *senderAddress, unsigned char *packetData, size_t dataBytes) {
|
||||||
switch (((char *)packetData)[0]) {
|
switch (((char *)packetData)[0]) {
|
||||||
case PACKET_HEADER_DOMAIN: {
|
case PACKET_HEADER_DOMAIN: {
|
||||||
|
@ -84,11 +95,14 @@ void AgentList::processAgentData(sockaddr *senderAddress, unsigned char *packetD
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PACKET_HEADER_PING: {
|
case PACKET_HEADER_PING: {
|
||||||
_agentSocket.send(senderAddress, &PACKET_HEADER_PING_REPLY, 1);
|
char pingPacket[dataBytes];
|
||||||
|
memcpy(pingPacket, packetData, dataBytes);
|
||||||
|
pingPacket[0] = PACKET_HEADER_PING_REPLY;
|
||||||
|
_agentSocket.send(senderAddress, pingPacket, dataBytes);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PACKET_HEADER_PING_REPLY: {
|
case PACKET_HEADER_PING_REPLY: {
|
||||||
handlePingReply(senderAddress);
|
timePingReply(senderAddress, packetData);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,7 @@ private:
|
||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
void handlePingReply(sockaddr *agentAddress);
|
void handlePingReply(sockaddr *agentAddress);
|
||||||
|
void timePingReply(sockaddr *agentAddress, unsigned char *packetData);
|
||||||
};
|
};
|
||||||
|
|
||||||
class AgentListIterator : public std::iterator<std::input_iterator_tag, Agent> {
|
class AgentListIterator : public std::iterator<std::input_iterator_tag, Agent> {
|
||||||
|
|
|
@ -706,6 +706,10 @@ int main(int argc, const char * argv[]) {
|
||||||
|
|
||||||
agentList->updateAgentWithData(agent, packetData, receivedBytes);
|
agentList->updateAgentWithData(agent, packetData, receivedBytes);
|
||||||
}
|
}
|
||||||
|
// If the packet is a ping, let processAgentData handle it.
|
||||||
|
if (packetData[0] == PACKET_HEADER_PING) {
|
||||||
|
agentList->processAgentData(&agentPublicAddress, packetData, receivedBytes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue