[Browser] Add debug info to QueryClient

This commit is contained in:
Koncord 2017-07-31 19:07:51 +08:00
parent 918658d383
commit bca594150c

View File

@ -7,6 +7,7 @@
#include <components/openmw-mp/NetworkMessages.hpp> #include <components/openmw-mp/NetworkMessages.hpp>
#include <iostream> #include <iostream>
#include <components/openmw-mp/Version.hpp> #include <components/openmw-mp/Version.hpp>
#include <qdebug.h>
using namespace RakNet; using namespace RakNet;
using namespace std; using namespace std;
@ -56,6 +57,9 @@ map<SystemAddress, QueryData> QueryClient::Query()
pmq->SetServers(&query); pmq->SetServers(&query);
status = GetAnswer(); status = GetAnswer();
qDebug() <<"Answer" << (status == ID_MASTER_QUERY ? "ok." : "wrong.");
return query; return query;
} }
@ -83,7 +87,7 @@ MASTER_PACKETS QueryClient::GetAnswer()
RakNet::Packet *packet; RakNet::Packet *packet;
bool update = true; bool update = true;
unsigned char pid = 0; unsigned char pid = 0;
int id; int id = -1;
while (update) while (update)
{ {
for (packet = peer->Receive(); packet; peer->DeallocatePacket(packet), packet = peer->Receive()) for (packet = peer->Receive(); packet; peer->DeallocatePacket(packet), packet = peer->Receive())
@ -94,8 +98,10 @@ MASTER_PACKETS QueryClient::GetAnswer()
data.Read(pid); data.Read(pid);
switch(pid) switch(pid)
{ {
case ID_DISCONNECTION_NOTIFICATION:
case ID_CONNECTION_LOST: case ID_CONNECTION_LOST:
qDebug() << "ID_CONNECTION_LOST";
case ID_DISCONNECTION_NOTIFICATION:
qDebug() << "Disconnected";
update = false; update = false;
break; break;
case ID_MASTER_QUERY: case ID_MASTER_QUERY:
@ -125,6 +131,7 @@ MASTER_PACKETS QueryClient::GetAnswer()
ConnectionState QueryClient::Connect() ConnectionState QueryClient::Connect()
{ {
ConnectionAttemptResult car = peer->Connect(masterAddr.ToString(false), masterAddr.GetPort(), TES3MP_MASTERSERVER_PASSW, ConnectionAttemptResult car = peer->Connect(masterAddr.ToString(false), masterAddr.GetPort(), TES3MP_MASTERSERVER_PASSW,
strlen(TES3MP_MASTERSERVER_PASSW), 0, 0, 5, 500); strlen(TES3MP_MASTERSERVER_PASSW), 0, 0, 5, 500);
@ -134,17 +141,20 @@ ConnectionState QueryClient::Connect()
switch (state) switch (state)
{ {
case IS_CONNECTED: case IS_CONNECTED:
qDebug() << "Connected";
return IS_CONNECTED; return IS_CONNECTED;
case IS_NOT_CONNECTED: case IS_NOT_CONNECTED:
case IS_DISCONNECTED: case IS_DISCONNECTED:
case IS_SILENTLY_DISCONNECTING: case IS_SILENTLY_DISCONNECTING:
case IS_DISCONNECTING: case IS_DISCONNECTING:
{ {
qDebug() << "Cannot connect to the master server "<< state;
//LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Cannot connect to master server: %d", masterAddr.ToString()); //LOG_MESSAGE_SIMPLE(Log::LOG_WARN, "Cannot connect to master server: %d", masterAddr.ToString());
return IS_NOT_CONNECTED; return IS_NOT_CONNECTED;
} }
case IS_PENDING: case IS_PENDING:
case IS_CONNECTING: case IS_CONNECTING:
qDebug() << "Pending";
break; break;
} }
RakSleep(500); RakSleep(500);