EDIT 2: Official Pusher widget is in the App Store! Very similar implementation to my version below.
EDIT: I've got a working demo for you.
Widget + Java code in test app here
Demo here
I just recently did a POC with WebSockets using Pusher. This service offers an inexpensive pub/sub API to easily communicate via WebSockets. With a few lines of JavaScript, Pusher does all of the client connection management for you. They also offer a REST API and a Java library to send messages from your server to clients, and there's even a Mendix widget on GitHub. For the POC I was involved in, we modified that code a bit (and I've published it above).
In the POC, were able to send a message from the Mendix server to our client's browser, triggering a microflow. That microflow fetched new data from the server and updated the UI. This model could be used for simple notifications or managing events, or even for a chat UI.
Here's a technical breakdown of how this works:
In terms of data flow, we used Pusher as a notification service to the client (i.e., the message basically told the client "hey there's something new for you on the server"). We did not include any real data in that message. In this way, all sensitive data still flows through the regular Mendix channels, and you can still use microflows to manage everything. Security is much simpler to manage this way than if sensitive application data were being sent in the Pusher message.
Side note: Managing a WebSocket connection from your Mendix server is probably possible for a Mendix deployment not in the Mendix cloud. I've seen one forum post where someone claimed to have a POC working. You'd need publish a WebSockets server in your JVM that listens on a different port than the rest of your app, and then write all of the server-side Java code and widget JS code yourself. This would a large effort, and again it wouldn't work in the Mendix cloud. Managing a WebSockets connection also goes against the principle of a Mendix 7 runtime being stateless, so I suspect you'd have a tough time horizontally scaling with this solution. For all of these reasons, I think it's best if your WebSocket connections are made via a non-Mendix server (whether that's a service like Pusher or a server you host using something like Socket.io)
Hi Kamil,
I'm not sure if this is the only way, but the only way I know of doing this is to use the microflow timer widget to trigger a microflow every X amount of seconds to refresh the objcect.
This widget will run a microflow that takes an object as a parameter and uses the change activity with the refresh in client setting.
https://appstore.home.mendix.com/link/app/27/Mendix/Microflow-Timer
Hope this helps!