picloud ping and fix big bugs

This commit is contained in:
2021-08-19 18:13:05 +03:00
parent f5af8a1da9
commit 4c0530d89a
13 changed files with 58 additions and 30 deletions

View File

@@ -72,10 +72,11 @@ void DispatcherClient::disconnected(bool withError) {
void DispatcherClient::readed(PIByteArray & ba) {
// piCout << size;
PIPair<PICloud::TCP::Type, PICloud::TCP::Role> hdr = tcp.parseHeader(ba);
// piCoutObj << "readed" << hdr.first << hdr.second;
if (hdr.first == PICloud::TCP::InvalidType) {
disconnected(true);
piCoutObj << "invalid message";
return;
}
if (authorised) {
@@ -87,7 +88,7 @@ void DispatcherClient::readed(PIByteArray & ba) {
disconnected(false);
return;
case PICloud::TCP::Data:
// piCoutObj << "TCP::Data";
//piCoutObj << "TCP::Data" << tcp.role();
if (tcp.role() == PICloud::TCP::Client) {
PIByteArray data = tcp.parseData(ba);
if (!data.isEmpty()) dataReaded(data);
@@ -99,11 +100,15 @@ void DispatcherClient::readed(PIByteArray & ba) {
else piCoutObj << "invalid data from server";
}
return;
case PICloud::TCP::Ping:
pingReceived();
return;
default:
piCoutObj << "unknown data";
//disconnected(true);
return;
}
}
} else piCoutObj << "invalid role";
} else {
switch (hdr.first) {
case PICloud::TCP::Connect: {
@@ -111,7 +116,8 @@ void DispatcherClient::readed(PIByteArray & ba) {
PIByteArray sn = tcp.parseConnect_d(ba);
if (hdr.second == PICloud::TCP::Server) registerServer(sn, this);
if (hdr.second == PICloud::TCP::Client) registerClient(sn, this);
return;}
return;
}
case PICloud::TCP::Disconnect:
disconnected(false);
return;