I should have done this a long time ago, but I finally made the callbacks in libwebsock asynchronous. Though libwebsock uses libevent and is event-driven, the callbacks supplied by the client code were being ran synchronously. For practical applications, this is unacceptable. I wanted to avoid multi-threading for as long as possible to keep things simple in the code base while I got things stable. I think I’ve finally reached that point and am introducing some simple multi-threading for asynchronous callbacks. This means that the callbacks are not as limited as they were previously. Previously, if you slept or blocked in your callback, the execution of the whole server was blocked in your callback. Like I said, this was pretty unacceptable for production use or practical application in the real world, but I’ve now removed this limitation. You can now sleep or do expensive operations inside your callback without affecting the server’s other clients or even further messages to the same client. This does introduce a bit of complexity as well. For example, if you sleep for 20 seconds in an onmessage callback and make a call to libwebsock_send_text afterwards, the client may already be disconnected! Of course, I’m going to be working on more checks and safety regarding these types of situations, but for now you have to watch out for these things on your own. If you have any questions, feel free to shoot me an email or comment.
Cheers and Merry Christmas!