-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Many optimizations for the client side of the library #5
base: master
Are you sure you want to change the base?
Conversation
pablorodiz
commented
Jun 9, 2016
•
edited
Loading
edited
- Response payload reading during handshake causes data loss if server sends first mesage on the payload. Added header section end (empty line) detection to solve.
- Added possibility to use transmit buffer on sendData.
- Added connected() function to allow application to check status.
- Added possibility to include other headers on the handshake (for authentication)
- And some corrections for compilation on ESP8266 and reduce logging when not DEBUGGING
… of the handshake response. So I added headers end detection (empty line) and stop reading, so the remaining bytes of the packet will be considered part of the websocket communication
…icaction) on the handshake request
…nnection is correct before calling any blocking-data-read function
Added one commit with sendEncodedData rewritten. With the original implementation it is very very slow to detect a disconnection. It takes as long as the time out of the socket multiplied by the number of bytes being sent, since all frames are send byte by byte. With my changes all the frame header is sent in only one write operation, and if it fails it does not try to send the payload, so only one timeout lapse is need to detect a connection failure. |
…o user can completely avoid the use of Stings
Strings use heap memory, so if you use them a lot, as when periodically reading messages received through the websocket, the heap memory gets fragmented and the program gets in a not enough memory exception (or at least that happens to me on ESP8266 after some time). So I created a new implementation of the getData function to avoid using Strings, and using char arrays (created on the stack) instead. |
…8266 where byte-by-byte sending is extremely slow. Be aware that if using buffered send "sendData" just stores messages in the buffer. To perform the actual send the program needs to call the new function "process" periodically in the main loop.
After finding a lot of problems, including system reboots, in the ESP8266 I decided to implement a new method for storing messages in a buffer before sending them. ESP8266 is very sensitive to small packets, since its transmit window is only 1. |
Changed README.md
…s. Created setters for those variables and class constructor
…uest and handshake return value to int so now the HTPP error code is returned. 200 is correct or any other value is for eeporting errors from the server
…or on evaluating response. Enhanced debugging by including logs on handshake and sending functions when debug is activated
…ogs when receiving messages.