Skip to content

Commit

Permalink
ensured that large messages will get processed properly if they arriv…
Browse files Browse the repository at this point in the history
…e in multiple packets
  • Loading branch information
boomanaiden154 committed Mar 7, 2020
1 parent ff9c9ea commit 59fe29c
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion websocket.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,16 @@ class websocket
payloadLength += (uint64_t)payloadLengthBuffer[7];
}
char* textBuffer = new char[payloadLength + 1];
SSL_read(SSLConnection, textBuffer, payloadLength);
uint32_t bytesRecieved = 0;
while(bytesRecieved < payloadLength)
{
bytesRecieved += SSL_read(SSLConnection, textBuffer, payloadLength - bytesRecieved);
}
textBuffer[payloadLength] = '\0';
listenerCallback(textBuffer, payloadLength);
}
pthread_exit(0);
return NULL;
}

int connectSocket(std::string address, int port, void (*listenerCallback)(char*,int))
Expand Down

0 comments on commit 59fe29c

Please sign in to comment.