Skip to content

Commit

Permalink
[network] Allow to post print() data to the studio before it is recon…
Browse files Browse the repository at this point in the history
…nected (iOS)
  • Loading branch information
Nicolas Bouquet committed Sep 5, 2016
1 parent 72e86e0 commit d57d761
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ios/iosplayer/iosplayer/giderosapi.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
10 changes: 7 additions & 3 deletions libnetwork/libnetwork.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions libnetwork/libnetwork.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -126,7 +126,7 @@ class Server : public NetworkBase
{
return serverSock_;
}

private:
SOCKET serverSock_;
SOCKET broadcastSock_;
Expand Down

0 comments on commit d57d761

Please sign in to comment.