|
|
|
|
@@ -25,6 +25,7 @@ PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode)
|
|
|
|
|
tcp.setRole(PICloud::TCP::Server);
|
|
|
|
|
tcp.setServerName(server_name);
|
|
|
|
|
setName("cloud_server__" + server_name);
|
|
|
|
|
eth.setReopenEnabled(false);
|
|
|
|
|
CONNECT1(void, PIByteArray, &streampacker, packetReceiveEvent, this, _readed);
|
|
|
|
|
CONNECTL(ð, connected, [this](){opened_ = true; piCoutObj << "connected" << ð tcp.sendStart();});
|
|
|
|
|
CONNECTL(ð, disconnected, [this](bool){
|
|
|
|
|
@@ -44,8 +45,10 @@ PICloudServer::PICloudServer(const PIString & path, PIIODevice::DeviceMode mode)
|
|
|
|
|
|
|
|
|
|
PICloudServer::~PICloudServer() {
|
|
|
|
|
piCoutObj << "~PICloudServer ..." << this;
|
|
|
|
|
stopAndWait();
|
|
|
|
|
stop();
|
|
|
|
|
close();
|
|
|
|
|
piCout << "wait";
|
|
|
|
|
waitThreadedReadFinished();
|
|
|
|
|
piCoutObj << "~PICloudServer done" << this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -69,10 +72,11 @@ bool PICloudServer::openDevice() {
|
|
|
|
|
eth.startThreadedRead();
|
|
|
|
|
ping_timer.start(5000);
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
ping_timer.stop(false);
|
|
|
|
|
eth.close();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
ping_timer.stop(false);
|
|
|
|
|
eth.close();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -80,12 +84,6 @@ bool PICloudServer::closeDevice() {
|
|
|
|
|
piCoutObj << "closeDevice" << this;
|
|
|
|
|
eth.stopAndWait();
|
|
|
|
|
ping_timer.stop(false);
|
|
|
|
|
clients_mutex.lock();
|
|
|
|
|
for (auto c : clients_) {
|
|
|
|
|
c->stopAndWait();
|
|
|
|
|
c->close();
|
|
|
|
|
}
|
|
|
|
|
clients_mutex.unlock();
|
|
|
|
|
eth.close();
|
|
|
|
|
for (auto c : clients_) {
|
|
|
|
|
delete c;
|
|
|
|
|
@@ -98,7 +96,7 @@ bool PICloudServer::closeDevice() {
|
|
|
|
|
ssize_t PICloudServer::readDevice(void * read_to, ssize_t max_size) {
|
|
|
|
|
//piCoutObj << "readDevice";
|
|
|
|
|
if (!opened_) openDevice();
|
|
|
|
|
else piMSleep(eth.readTimeout());
|
|
|
|
|
//else piMSleep(eth.readTimeout());
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|