From d57d7612b800c90a78609a97a1713c9b729f1ce6 Mon Sep 17 00:00:00 2001 From: Nicolas Bouquet Date: Mon, 5 Sep 2016 17:51:58 +0200 Subject: [PATCH] [network] Allow to post print() data to the studio before it is reconnected (iOS) --- ios/iosplayer/iosplayer/giderosapi.mm | 2 +- libnetwork/libnetwork.cpp | 10 +++++++--- libnetwork/libnetwork.h | 4 ++-- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/ios/iosplayer/iosplayer/giderosapi.mm b/ios/iosplayer/iosplayer/giderosapi.mm index 0ed32a08c..4a44060dd 100644 --- a/ios/iosplayer/iosplayer/giderosapi.mm +++ b/ios/iosplayer/iosplayer/giderosapi.mm @@ -184,7 +184,7 @@ void printToServer(const char *str, int len) memcpy(buffer + 1, str,size-2); buffer[size-1]=0; - server_->sendData(buffer, size); + server_->sendData(buffer, size, true); free(buffer); } diff --git a/libnetwork/libnetwork.cpp b/libnetwork/libnetwork.cpp index a46b9d3e7..dc5784011 100644 --- a/libnetwork/libnetwork.cpp +++ b/libnetwork/libnetwork.cpp @@ -420,10 +420,14 @@ void NetworkBase::tickRecv(NetworkEvent* event) } } -int NetworkBase::sendData(const void* data, unsigned int size) +int NetworkBase::sendData(const void* data, unsigned int size, bool noCheck) { - if (isConnected() == false) - return -1; + if (!noCheck) { + if (isConnected() == false) + return -1; + } else + if (sendQueue_.size() > 1024) //Avoid queue size beginning too big in forced mode (print mainly) + return -1; QueueElement* queueElement = new QueueElement(data, size, 0); sendQueue_.push_back(queueElement); diff --git a/libnetwork/libnetwork.h b/libnetwork/libnetwork.h index c68138bd3..8a655278f 100644 --- a/libnetwork/libnetwork.h +++ b/libnetwork/libnetwork.h @@ -59,7 +59,7 @@ class QueueElement; class NetworkBase { public: - int sendData(const void* data, unsigned int size); + int sendData(const void* data, unsigned int size, bool noCheck=false); void cancelSend(); SOCKET clientSock() const @@ -126,7 +126,7 @@ class Server : public NetworkBase { return serverSock_; } - + private: SOCKET serverSock_; SOCKET broadcastSock_;