some PICloud and PIEthernet fixes
This commit is contained in:
@@ -11,7 +11,7 @@ int main(int argc, char * argv[]) {
|
||||
PICloudClient c("127.0.0.1:10101");
|
||||
// c.setReopenEnabled(true);
|
||||
PICloudServer s("127.0.0.1:10101");
|
||||
PIVector<PICloudServer::Client *> clients;
|
||||
auto clients = new PIVector<PICloudServer::Client *>();
|
||||
CONNECTL(&tm, tickEvent, ([&](void *, int){
|
||||
if (c.isConnected()) {
|
||||
PIString str = "ping";
|
||||
@@ -19,7 +19,7 @@ int main(int argc, char * argv[]) {
|
||||
c.write(str.toByteArray());
|
||||
}
|
||||
if (s.isThreadedRead()) {
|
||||
for (auto cl : clients) {
|
||||
for (auto cl : *clients) {
|
||||
if (cl->isOpened()) {
|
||||
PIString str = "ping_S";
|
||||
piCout << "[Server] send to" << cl << ":" << str;
|
||||
@@ -40,7 +40,7 @@ int main(int argc, char * argv[]) {
|
||||
CONNECTL(&c, disconnected, ([](){piCout << "disconnected";}));
|
||||
CONNECTL(&s, newConnection, ([&](PICloudServer::Client * cl){
|
||||
piCout << "[Server] new client:" << cl;
|
||||
clients << cl;
|
||||
clients->append(cl);
|
||||
CONNECTL(cl, threadedReadEvent, ([cl, &rnd](const uchar * readed, ssize_t size){
|
||||
PIByteArray ba(readed, size);
|
||||
PIString str = PIString(ba);
|
||||
@@ -53,7 +53,7 @@ int main(int argc, char * argv[]) {
|
||||
CONNECTL(cl, closed, ([&clients, cl](){
|
||||
piCout << "[Server] client closed ..." << cl;
|
||||
cl->stop();
|
||||
clients.removeAll(cl);
|
||||
clients->removeAll(cl);
|
||||
piCout << "[Server] client closed ok" << cl;
|
||||
}));
|
||||
cl->startThreadedRead();
|
||||
|
||||
Reference in New Issue
Block a user