just awaiting and only returning on data received to port 1 or 2
figuring out if the function can access appVars or pageVars scope to write async’ly
In all cases, the function continues with an empty output but 200ms later the console logs out the initial received data and also logs out to console any subsequent messages received.
Open questions:
Is there any way to have a function able to access the appVars or pageVars scope directly e.g. self.appVars.variable1 kind of thing?
Is it possible to have custom javascript functions push data forward in the flow more than the initial output?
Is there a different way to accomplish what I’m attempting that I’m not understanding, yet?
The pattern here would be to use the internal API for sending events in the JS callback, which can then be received with the Receive event node.
If you link to the page where this JavaScript box is, I can enable this for you but it’ll be at your own responsibility, as it’s a secret undocumented feature still.
I added the logic – the secret sauce is exposing the internal supersonic and contextId properties (which is something regular users can’t do), then using supersonic.api.events.send function in the callback. The Receive event node is below the JS box. Let me know if it works!
You can “smuggle” the logic into another app by copypasting the JS node onto e.g. a button component’s logic canvas, then copying the button component over via CMD+C / CMD+V – the logic gets copied along the component, and now you have a JS box with the internal props exposed in your other app too.
Also, any tips or best practices for being a good citizen with websockets…? When the app exits, what’s the best way to ensure the socket is closed on the way out? (I don’t see an app event for like “on exit” or “page unmounted”, for example)
How best to test the socket periodically and reset it if the connection is down? Can the socket handle be stored in an app var, and a separate function test and reset it periodically?
Hey @Harri_Sarsa, could I also please access the internal API code you shared with the others? I also need to use websockets in order to allow real-time connection between app and server. Thanks!
Is there a chance you could also implement the same functionality on this app?,
I have the same problem, I can log and alert the received message but I can’t store it in a variable.
Here is the link to the app: https://platform.appgyver.com/builder/applications/264214/pages/4
could you please share the AG setup and code that you’re using? I’m pretty new to socket.io, and need some guidance how to establish the connection within Appgyver page. Thank you!
Hi! By default you should not be using any of those commands. There are no examples for it because it’s a workaround and we by default do not want anyone to be using it if at all possible to do in another way.
I’ve added the logic - the secret sauce is exposing the built-in supersonic and contextId properties (something regular users cannot do) and then using the supersonic.api.events.send function on the return of call. The Receive event node is below the JS box. Let me know if it works!