morrissinger / ESP8266-Websocket

A websocket library for the ESP-8266.
305 stars 119 forks source link

Changes for WebSocketServer::sendEncodedData() #5

Closed flynnwt closed 8 years ago

flynnwt commented 8 years ago

I was able to get this working as a server with some small changes to sendEncodedData(). I was getting SLOWWW speeds (like 2 seconds/msg for small sizes and 20 seconds/msg for 100-bytes). Changing the write() loop to a single print() fixed this (now getting about 1.6 messages/sec).

//for (int i=0; i<size; ++i) {
//    socket_client->write(str[i]);
//}
socket_client->print(str);

I tried doing longer ones but got protocol errors for length > 125. There's another small change in sendEncodedData().

socket_client->write((uint8_t) (size & 0xFF)); //  was &&

Now getting about 1/sec at 1000 bytes and .8/sec at 2500 bytes. At 4000 bytes the poor little bugger choked.

morrissinger commented 8 years ago

So, this appears to be an improvement. Can you do a PR?