Awaiting another request handler from ".ws open:" function #790
Unanswered
soundsmagic
asked this question in
Q&A
Replies: 3 comments
-
"Can't code your app for you"
No need to be rude. I'm quite new to programming and am just trying to learn. Of course I realize that this is application level, I just got stuck in my thinking and thought that I'll post the question on the Discussions page in the off chance that there are some cool under-the-hood feature of the library that could be applicable in my strange situation. I didn't wish for someone to code my app for me, I just described one situation in one small part of the application and hoped for a little nudge in the right direction since I felt my thinking was jammed. And I got that nudge, so thank you!
(What I'm trying to build is a web-based remote control application for the music program Ableton Live, to be run on a local network, using this library - https://github.com/leolabs/ableton-js - to upgrade my thesis project - https://github.com/soundsmagic/Ableton-React-Remote - to Websockets.)
Anyway, thanks again for the tip and sorry to have wasted your time and discussion space on the library page. I promise I'll think again before posting another question.
/John
…________________________________
Från: e3dio ***@***.***>
Skickat: den 21 augusti 2022 01:14
Till: uNetworking/uWebSockets.js ***@***.***>
Kopia: John Svensson ***@***.***>; Author ***@***.***>
Ämne: Re: [uNetworking/uWebSockets.js] Awaiting another request handler from ".ws open:" function (Discussion #790)
No idea what you are trying to do, but this is application level stuff and is something you need to code yourself. If data is not avail on open then don't open websocket until data is ready, or don't use open event use message event. Can't code your app for you
—
Reply to this email directly, view it on GitHub<#790 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ASEWSMWRR6QYQCL2MGV5RF3V2FRGHANCNFSM57D3UWNQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks a lot for taking the time to provide more examples. I'll give them a go the next time I sit down with the project.
…________________________________
Från: e3dio ***@***.***>
Skickat: den 21 augusti 2022 18:07
Till: uNetworking/uWebSockets.js ***@***.***>
Kopia: John Svensson ***@***.***>; Author ***@***.***>
Ämne: Re: [uNetworking/uWebSockets.js] Awaiting another request handler from ".ws open:" function (Discussion #790)
You should get rid of that wholeState route and just use the open event:
const app = App()
.ws('/ws', {
open: async (ws) => {
const state = await apiService.getWholeState();
state.propList.forEach(prop => {
prop.addListener('trigger', (value) => ws.send(JSON.stringify({ id: prop.id, value })));
});
ws.send(JSON.stringify(state));
}
})
—
Reply to this email directly, view it on GitHub<#790 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ASEWSMS4MRYNJMTBUL4WEGDV2JH2NANCNFSM57D3UWNQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
You're certainly right that latency is a big issue in music applications! (Been working with DAWs for 16 years...) Unfortunately, things point to a limitation in Ableton Lives communication with the Python scripts it runs, locking interaction to a timed interval (found some old numbers of 60 ms). So my initial thoughts is to just implement features that are not time-sensitive, or features that only need an accuracy of 500-1000 ms. Later on I might start as a "side project" to measure how low latency I can achieve, to see if I can include really timing sensitive features - then I'll surely look into your new library! Thanks for the offer of help though!
…________________________________
Från: e3dio ***@***.***>
Skickat: den 23 augusti 2022 02:25
Till: uNetworking/uWebSockets.js ***@***.***>
Kopia: John Svensson ***@***.***>; Author ***@***.***>
Ämne: Re: [uNetworking/uWebSockets.js] Awaiting another request handler from ".ws open:" function (Discussion #790)
If it is live music app low Latency is important, Binary encoding is 5 to 10 times faster than JSON encoding and much smaller, if you want to try Binary websocket messages I just coded new library https://github.com/e3dio/packBytes to make it as easy as possible, I could help with that if needed
—
Reply to this email directly, view it on GitHub<#790 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/ASEWSMXCI7ZC2JWLDTE6ANDV2QK75ANCNFSM57D3UWNQ>.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi and thanks for an excellent and helpful WS tool!
I'm trying to set up an application where uWebsockets are tying together a frontend and an API. I'm using RTK Query in the frontend for the data fetching.
My plan is to make a regular HTTP request at startup to fetch the whole "state" from the backend API. At the same time I set up a Websocket connection to be able to receive updates on this "state" from the backend.
When the Websocket connection is created in my uWebsocket App, I want to use the ".ws open" function to set up some "listeners" at the API. But to set up these listeners, I need things that are returned from the API when that first regular HTTP request is done - and that takes a bit of time. This leads to the situation where I don't have what I need at the time when the ".ws open" function tries to add the "listeners". I'll try to illustrate with some simplified code:
I'll admit I'm still not confident with async programming in JS/TS... Can I "await" the '/wholeState' handler in any way, or set something "outside" the handlers to await, like the coolProps array or something?
Beta Was this translation helpful? Give feedback.
All reactions