picloud multithread fix
This commit is contained in:
@@ -62,7 +62,9 @@ void PICloud::TCP::sendStart() {
|
|||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << header;
|
ba << header;
|
||||||
ba.append(suuid);
|
ba.append(suuid);
|
||||||
|
mutex_send.lock();
|
||||||
streampacker->send(ba);
|
streampacker->send(ba);
|
||||||
|
mutex_send.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -70,7 +72,9 @@ void PICloud::TCP::sendConnected(uint client_id) {
|
|||||||
header.type = PICloud::TCP::Connect;
|
header.type = PICloud::TCP::Connect;
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << header << client_id;
|
ba << header << client_id;
|
||||||
|
mutex_send.lock();
|
||||||
streampacker->send(ba);
|
streampacker->send(ba);
|
||||||
|
mutex_send.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -78,7 +82,9 @@ void PICloud::TCP::sendDisconnected(uint client_id) {
|
|||||||
header.type = PICloud::TCP::Disconnect;
|
header.type = PICloud::TCP::Disconnect;
|
||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << header << client_id;
|
ba << header << client_id;
|
||||||
|
mutex_send.lock();
|
||||||
streampacker->send(ba);
|
streampacker->send(ba);
|
||||||
|
mutex_send.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -88,7 +94,9 @@ int PICloud::TCP::sendData(const PIByteArray & data) {
|
|||||||
ba << header;
|
ba << header;
|
||||||
ba.append(data);
|
ba.append(data);
|
||||||
// piCout << "[PICloud::TCP] sendData" << ba.toHex();
|
// piCout << "[PICloud::TCP] sendData" << ba.toHex();
|
||||||
|
mutex_send.lock();
|
||||||
streampacker->send(ba);
|
streampacker->send(ba);
|
||||||
|
mutex_send.unlock();
|
||||||
return data.size_s();
|
return data.size_s();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -98,7 +106,9 @@ int PICloud::TCP::sendData(const PIByteArray & data, uint client_id) {
|
|||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << header << client_id;
|
ba << header << client_id;
|
||||||
ba.append(data);
|
ba.append(data);
|
||||||
|
mutex_send.lock();
|
||||||
streampacker->send(ba);
|
streampacker->send(ba);
|
||||||
|
mutex_send.unlock();
|
||||||
return data.size_s();
|
return data.size_s();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,7 +118,9 @@ void PICloud::TCP::sendPing() {
|
|||||||
PIByteArray ba;
|
PIByteArray ba;
|
||||||
ba << header;
|
ba << header;
|
||||||
ba.append(suuid);
|
ba.append(suuid);
|
||||||
|
mutex_send.lock();
|
||||||
streampacker->send(ba);
|
streampacker->send(ba);
|
||||||
|
mutex_send.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include "pip_cloud_export.h"
|
#include "pip_cloud_export.h"
|
||||||
#include "pistring.h"
|
#include "pistring.h"
|
||||||
|
#include "pimutex.h"
|
||||||
|
|
||||||
|
|
||||||
class PIEthernet;
|
class PIEthernet;
|
||||||
@@ -86,6 +87,8 @@ private:
|
|||||||
PIByteArray suuid;
|
PIByteArray suuid;
|
||||||
PIString server_name;
|
PIString server_name;
|
||||||
PIStreamPacker * streampacker;
|
PIStreamPacker * streampacker;
|
||||||
|
PIMutex mutex_send;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user