robotconscience / ofxLibwebsockets

[Deprecated] openFrameworks wrapper of libwebsockets for WebSocket client and server functionality
Other
171 stars 69 forks source link

Feature Request - blocking methods for send() and receive()? #97

Open armadillu opened 7 years ago

armadillu commented 7 years ago

Hi! I'm wondering how hard would it be to have blocking methods for send() and receive() for server & client, kinda like ofLoadURL() vs ofLoadURLAsync().

Async is nice, but sometimes you need to deal with protocols that requires a lot of back & forth and it becomes a mess pretty quickly with all the callbacks. (Currently talking to Chrome using DevTools in ofxChrome)

robotconscience commented 6 years ago

Hey Oriol! Sorry for the crazy delay—realizing I have something screwed up with my Github notifications. I don't do a ton of OF dev anymore, but do try to keep this addon up to date if I can.

Did you end up digging into this? It's not impossible per se, but threading is woven pretty deep into lws. There's a lot of funkiness that comes in when sending big packets of data, and you'd be stuck in possibly a long loop if/when you send or receive a big packet. Would need to refactor connect, disconnect checks, etc...!