Possible to send commands/messages from a Web App to a running app on the client?

Hi,

For my needs, I’m looking for a way to do the following:
• Run a Web app on my existing server; it already has a domain name.
• On device 1, which is a computer, run a Xojo desktop app. Also, connect to the web app using a browser (or within the desktop app?).
• On device 2, connect to the same web app.
• Be able to use the session of the web app of device 2 to send a message to the other session (which runs on device 1); the message is then relayed to the app on device 1.

In the end, I could control my Xojo app on device 1 from my website on device 2.
The part I don’t get is how to send the message from the web app to the desktop app. I’d have to either escape the browser’s sandbox (which is a bad thing in the first place) or have the desktop app always listening to the web app (how would I do that?).
Is something like this doable?

You might be able to accomplish this using GoToURL by registering a URL Scheme. That said, the user would probably be prompted every time to allow it.

Otherwise I suspect the easiest way would be to have the app periodically call the web app through HandleURL and have it retrieve messages that are waiting for it.

If you needed something more direct, you could add a ServerSocket and listen for connections on another port, but you’ll need to set up security yourself to prevent bad actors from exploiting your app.

2 Likes

Thanks Greg, I’ll try that. Option 2 seems the best as I see my needs now.

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.