Is it possible to include a RESTful server in a Desktop app?

  1. 2 weeks ago

    Does anyone remember FileMaker Pro? Like freedom, it was both wonderful and horrible at the same time... but one of the things that made it wonderful was the idea that you could use it to create a database on your computer and share it with other computers running FMP on the same network. It could be a list of employee phone numbers or the latest pricing from distribution... you could simply turn on sharing and others could connect to your data. Likewise, you could look out on the network and connect to any FMP database that was being shared.

    I'm pretty sure that I know the answer to this question but basically, I would like to know if it's possible to run a RESTful API to serve a database using the Desktop version of Xojo. Ideally, I'd like to bake the server right into the same app that acts as the client.

    Seeing that I can't seem to fine HandleSpecialURL anywhere in Desktop, I have a feeling that the answer is to create two apps, a Web app to be the REST server and a Desktop app to be the client.

    The easiest way is probably to create two apps as you suggest, but then communicate between them with Xojo's built in IPC classes to keep things a bit faster and less race condition prone than using your own local files: https://docs.xojo.com/IPCSocket

    Alternatively, you could use the Aloe library (https://aloe.zone/) to provide a server directly from your desktop app. It would need to be run on it's own thread to not interrupt processing of GUI events.

    If you do make a web service, use standard security practices and it's perfectly safe. Lots of very successful software does this, but you have to be careful.

    Alternatives:
    If you just want your own apps to communicate locally, just stick with IPC.

    If you need apps across multiple machines to communicate you may also want to think of using something like CubeSQL (https://www.sqlabs.com/cubesql ) as the central server -- it handles encryption and authentication already so it's a good choice if you just need to share data (maybe even some custom logic via its plugin system).

  2. Beatrix W

    May 12 Pre-Release Testers Europe (Germany)

    HandleSpecialURL doesn't do much special. You need a server socket, you need to define a grammar and parse the url.

  3. Tomas J

    May 12 Pre-Release Testers, Xojo Pro Europe (Germany)
    Edited 2 weeks ago

    It's possible, but you would need a helper app acting as server side-by-side to your desktop app. By saying that I have to add that this is a bad application design. You're setting up a local service, which needs an open port and makes your client computer vulnerable. You have to decide how to control this service to prevent running when your desktop app has stopped intendedly or unintendedly. It increases the chance of recieving annoying warning messages by firewalls and anti-malware software. If you want to commuicate via Webservices, then you must do this via TLS encrypted communication (and in best case with support of other technologies like HSTS etc.) otherwise all your data is transfered in cleartext. Any other desktop app (or in worst case remote software e.g. proxy) could read/capture/manipulate your desktop-client communication and would threaten the integrity of your data.

    Bottomline: Don't do this.

  4. Beatrix W

    May 13 Pre-Release Testers Europe (Germany)

    @Kristin G : if you need a highly scalable, secure etc solution then Tomas Jakobs is of course correct. If you need a simple, local network solution then you can use a simpler approach.

  5. Tomas J

    May 13 Pre-Release Testers, Xojo Pro Europe (Germany)
    Edited 2 weeks ago

    @Beatrix W ...a simpler approach.

    e.g. communicating with an local SQLite DB or local textfiles directly.

  6. Isaac R

    May 13 Pre-Release Testers, Xojo Pro Answer Minnesota, USA

    The easiest way is probably to create two apps as you suggest, but then communicate between them with Xojo's built in IPC classes to keep things a bit faster and less race condition prone than using your own local files: https://docs.xojo.com/IPCSocket

    Alternatively, you could use the Aloe library (https://aloe.zone/) to provide a server directly from your desktop app. It would need to be run on it's own thread to not interrupt processing of GUI events.

    If you do make a web service, use standard security practices and it's perfectly safe. Lots of very successful software does this, but you have to be careful.

    Alternatives:
    If you just want your own apps to communicate locally, just stick with IPC.

    If you need apps across multiple machines to communicate you may also want to think of using something like CubeSQL (https://www.sqlabs.com/cubesql ) as the central server -- it handles encryption and authentication already so it's a good choice if you just need to share data (maybe even some custom logic via its plugin system).

  7. @ Isaac : Aloe looks amazing! Thanks for that! Running this in it's own thread sounds exactly like what I was looking for.

    Thanks to all who replied. :-)

or Sign Up to reply!