Delphi 10.3 Rio FireMonkey apps are cross platform with a single codebase and single UI that target the Android, IOS, Macos, Windows, and Linux platforms (FMXLinux was recently added to Delphi 10.3 Rio Enterprise and Architect). You can also deploy Delphi FireMonkey apps to the web using websockets and HTML5. The method for doing this is basically the FireMonkey app runs on a Windows or Linux server and it’s canvas draws are sent to the web browser via a websocket. Each user connection runs one copy of the app on the server (so one user one app). The server is running the app so it needs enough hardware for however many concurrent apps you want to run.
For FireMonkey Windows apps this can be achieved through Thinfinity VirtualUI. Thinfinity is a commercial product which a cost per concurrent user. The user connects to the Thinfinity server, Thinfinity launches the FireMonkey app, handles the user input, and sends the drawing to the browser client. Thinfinity has been around for quite a few years and I would consider it a pretty mature product. It supports enterprise features like load balancing and ActiveDirectory login. You can also use it with Windows apps written in other languages (like C++ and C#).
For FireMonkey Linux apps this can be achieved through FMXLinux and Gtk Broadwayd. FMXLinux is also a commercial product but has recently been made available to Delphi 10.3 Rio Enterprise and Architect developers for free (just open GetIt and install it). FMXLinux allows FireMonkey apps to run on Linux desktops using the Gtk UI library. Gtk comes with an application called Broadwayd which will stream the Gtk app out to HTML5 via websockets. Broadwayd runs on a single port (8080) per app and you can click compile in Delphi 10.3 Rio and see your FireMonkey app in the browser served up from you Linux machine if you start the broadwayd server prior to deployment. If you want to run a pool of FireMonkey apps on Linux like Thinfinity does on Windows you can set up a Linux bash script to do so.
The purpose of the bash script is to run X number of FireMonkey apps through broadwayd (remember 1 app per port) and then use a load balancer make all of the apps accessible via a single port. In order to do this second part there is a Linux package called balance which can do this for you. One limitation of it is that it will only do 16-32 apps in it’s app pool unless you compile the source yourself. You can install balance with “sudo apt install balance” on Ubuntu or “yum install balance” on CentOS. Broadwayd and balance are open source and free applications but the solution is also not as polished as Thinfinity UI. You could also build something in Delphi using TidMappedPortTCP instead of using balance. For commercial deployments I’d recommend going with Thinfinity though.
Here is the sample bash script I put together which handles hosting multiple apps on a single port for you. Save the script as gtkcloud.sh and “chmod +x gtkcloud.sh”. It takes two parameters. The first parameter is the path to the app you want to run and the second parameter is the port you want to run the load balanced app on.
#!/bin/bash for i in {1..16} do nohup broadwayd :$i & export GDK_BACKEND=broadway export BROADWAY_DISPLAY=:$i $1 & #echo "" done servers="" for ii in {1..16} do let port=8080+$ii servers="$servers localhost:$port:1 %" done echo $servers balance $2 $servers
Example usage is as follows and would host 16 instances of /root/FireMonkeyPaintDemo on port 81.
./gtkcloud.sh /root/FireMonkeyPaintDemo 81
And that is all there is to it. You can run your Delphi FireMonkey apps on Android, IOS, Macos, Windows, Linux, AND the web using a single codebase and single UI.
Download the gtkcloud broadwayd + balance bash script for hosting Delphi FireMonkey FMXLinux apps.
Don’t have Delphi 10.3 Rio Enterprise or Architect? You can still use FMXLinux with you Delphi Pro FireMonkey apps.
Very nice tip. Thanks.
However, all solutions above only solve the GUI parts. Once we need to use hardware devices, e.g. camera and audio devices, is there any way to do so other than duplicating our apps by IntraWeb / UniGUI / TMS WebCore or RealThinClient, please?
The need to have web app is very significant nowadays but the more features multi-platform apps must have the harder work duplication becomes 🙁 even unbearable