ofxLws - an updated Libwebsockets addon

This addon allows you to create websockets for both client and server OF apps. In simple terms, this means you can, among other things, talk to a web page or web app through a web socket.

Currently I’m using this to talk from OF to a p5.js web app.

This is an update to ofxLibwebsockets in order to be able to use more recent versions that broke the older API. I’m currently using version 3.2 but it should work with the latest 4.16 version as well. I renamed it in order to be able to test both addons in the same project.

Happy to conflate this back into ofxLibwebsockets if @robotconscience is interested, although it will break a bunch of older projects that rely on that addon.

More info on Libwebsockets: https://libwebsockets.org/

1 Like

@grimus fantastic! So glad you did this, have been unable to support this addon for some time.

I’ll for now at least add a link to your add on in the Readme. Happy to try to do a merge in if that makes sense — I think things are tagged OK for folks that want to keep their old versions going.

1 Like

Currently using it for a project, I’ll look at possibly merging it when I’m done. Thanks for you original work, it was super helpful (Libwebsockets documentation is not the best)

hey @grimus,
just to my understanding…

So, libWebSockets can be useful to link two OFapp’s?
Or only when linking an OFapp to a webApp?
Or we should go maybe to some other addon like bakercp/ofxHTTP?

Also, compared to the easiest OSC/UDP, what I understand is that using TCP could be required in some cases to not lose any message, and fastest speed or multicast is not required.

I opened an issue, bc I am having errors on Windows…

Currently, I am looking for something to send something like:

A struct/bundle with (ie) :
a (variable size) vector of ofColor’s, a string, a float, an ofColor, and maybe a JSON file used as an ofParameterGroup preset,
To connect (one direction) between one server OFapp and one client OFapp.

Any suggestion to something like this scenario?

Hi @moebiussurfing, to communicate between two OF apps you’re better off using ofxOsc I think, or ofxNetwork. My addon is about talking to a browser and an OF app.

Regarding your question, have you tried OSC bundles?

ok. thanks. I’ll try OSC bundles.
I used https://github.com/2bbb/ofxPubSubOsc many times but without bundles,
(but I thought about an OSC alternative to avoid some not received messages because UDP)

I’ll check https://openframeworks.cc/documentation/ofxNetwork/ too, I understand that you mean this bundled classes not an addon. right?

Just use ofxOsc, it comes default with OF. Have a look at the file ofxOscSender.h, there you’ll find functions like
void sendBundle(const ofxOscBundle &bundle);

If you are constantly sending the data, then it doesn’t matter if you miss a packet. Othewise, just use TCP, it’s used in ofxNetwork

1 Like