Custom client for websocket server?

Could the OSC websocket server be used with a custom client? Can we consider its API public and stable?

It's kind of stable I guess but I'm not sure it can be considered public since I never documented it... also it may not be the cleanest part of the code base :). What would be the use case ?

The use case is a custom (PWA) web app with some OSC functionalities. Open Stage Control server could be used as the bridge between the app and the OSC target application.
Are there better ways to achieve that?

Otherwise a custom backend (on top of osc.js's own WebSocketPort and UDPPort) will be implemented.

Digging into the server code I noticed that the sendOsc callback relies on a widgets table that is populated inside the addWidget callback.

I suspect that this is enough to state that the server component can't be used with a generic client app.

Interesting question @giohappy. I started developing my JavaScript application with Lemur and adapted the websockets example in Colin Clark's osc.js to route Lemur messages. After (happily) porting the Lemur interface to Open Stage Control I noticed that osc.js was part of this package and began to wonder if my architecture was not the best.

It wouldn't be a problem to add callbacks to the existing backend in o-s-c in order to provide a generic API, pull requests are welcome :).

1 Like

@jean-emmanuel what if we support messaages with data not bound to the widget data table inside sendOsc?

If the clientId is set it will behave the way it is now, otherwise it will read an optional data parameter which the caller will populate with the OSC message(s).

clientId should always be set but regardless it wouldn't be a problem to allow ignoring the widget table, the most simple way would be to check for the presence of data.h (widget hash / unique id), and if not present, ignore the table and use

data.address: osc address (string)
data.target: array of target strings
data.preArgs: array of values
data.typeTags: string
data.v: widget value or array

I was going to implement the solution and I saw that you already did it.
Thanks @jean-emmanuel!

I've been already able to make a test with my (react native) and it works perfectly. The only thing I had to do was the ping/pong heartbeat, otherwise the server was killing my client.