EZ Websocket

Content Type: Module
Categories: Utility,User Interface

Overview

Allow for real-time server to client communication using websockets without external dependencies or runtime configuration.

Includes listener widgets for both web and native.

Documentation

https://youtu.be/izg8a6bgMoc
Demo urlhttps://github.com/nathan-JJRplus/EZWebsocket/tree/main/tests/testProject

EZWebSocket

Allow for real-time server to client communication using websockets without external dependencies or runtime configuration

Features

  • ✅ Easily set up 1 or more websocket servers

  • ✅ Configure 1 or more client-side actions

  • ✅ Configure either limited or unlimited sessiontimeout

  • ✅ Configure action to perform on sessiontimeout

  • ✅ Configure action to perform on user navigating away

  • v1.1.0 update Configure server-side microflow to be fired on websocket close

  • v1.3.0 update Added listener widget for native

  • v1.4.0 update Added message feature

  • v1.4.2 update Added multi-instance support as a separate addon module link

  • v2.0.0 ping/pong update

    • Added keepalive using websockets native ping/pong mechanism
    • Removed sessionTimeout parameter from easy websocket initialization for even easier websocket initialization
    • Added advanced websocket initialization for tweaking session timing parameters

Usage

Initialize webserver

  1. Add one of the JA_AddWebsocketEndpoint_XXX-actions to your afterstartup flow

    See the documentation tab of the Java actions' properties to check which one fits your usecase

  2. Create a websocketidentifier, this will also be the path to the websocketserver

    I recommend storing this inside a constant with client exposure for reuse in notify action and the websocket client widget

If you initialize the websocket with one of the JA_AddWebsocketEndpoint_XX_CallMicroflowOnDisconnect actions you will need to configure the following as well:

  1. Select the onCloseMicroflow, the microflow can contain one string parameter

  2. Fill in the name of the string parameter inside onCloseMicroflowParameterKey

Setup client connection

General tab

  1. Place the EZ Websocket client widget inside a context entity

  2. Configure the object Id

Note that the object database id is not available here, you will have to provide your own unique object id

  1. Fill the websocket identifier with the same identifier from the websocket initialization

  2. Configure one or more trigger/action combination(s)

Message handling tab

Message attribute: Configure attribute to receive messages sent directly from the notify action on

Websocket close behaviour tab

Timeout action: If you configured a sessiontimeout during the initialization you can configure the action to perform on sessiontimeout here

Note that you might need to use the advanced websocket initialization to turn off the keepalive mechanisim

Navigate action: Executes action when the websocket component unrenders, examples of this are:

  • User navigates away from the page

  • User closes the page

  • The component becomes invisible

This does not get fired if the user closes the tab or the browser, use the onCloseMicroflow functionality instead

On close MF parameter: Only use this if the websocket is initialized using one of the JA_AddWebsocketEndpoint_XX_CallMicroflowOnDisconnect actions

  • This is the string parameter that will be passed to the on close microflow

Notify all subscribers

  1. Add JA_Notify action to your microflow

  2. Configure the object Id of which you want to notify the subscribers of

  3. Fill the websocket identifier with the same identifier from the websocket initialization

  4. Configure the action trigger configured in the client widget

and/or

  1. Add a message you want to send to the clients

Note that the message attribute gets set before the action is executed so that the message is directly available inside the action

Issues, suggestions and feature requests

Issues

Releases

Version: 2.0.1
Framework Version: 9.24.25
Release Notes: Due to popular demand, backported the project to mendix 9.24 LTS
Version: 2.0.0
Framework Version: 10.6.10
Release Notes: - Added keepalive using websockets native ping/pong mechanism - Removed sessionTimeout parameter from easy websocket initialization for even easier websocket initialization - Added advanced websocket initialization for tweaking session timing parameters - ❗This update will break your current ASU initialization
Version: 1.4.2
Framework Version: 10.6.10
Release Notes: - Fixed issue where action could not be performed when parameter came from datasource micro/nanoflow - Fixed testproject path so that the fixes from 1.4.1 are actually in this release as well - Updated testproject to 10.6.10 MTS - Added simple multi-instance solution to be released as an addon
Version: 1.4.1
Framework Version: 9.24.15
Release Notes: Fixed issue where too many user sessions would result in performance issues Fixed issue where using a messageattribute from a datasource flow would result in incorrect results Updated testproject to Mendix LTS version 9.24.15
Version: 1.4.0
Framework Version: 9.18.1
Release Notes: New feature - Added the option to send a message to the clients through the notify action - Client widgets now have the option to configure an attribute to receive messages on - Notify action can now send a message, an action or both Fixes - Fixed bug where navigate action would not fire in case of a websocketendpoint without microflow - Removed some leftover debugging logs
Version: 1.3.0
Framework Version: 9.18.1
Release Notes: - Added websocket listener widget for native - Renamed web widget package, make sure to remove jjr+.EZWebsocket.mpk from your widgets folder and use jjrplus.EZWebsocket.mpk instead
Version: 1.2.1
Framework Version: 9.18.1
Release Notes: Fixed mistake with the activesessions iterator
Version: 1.1.0
Framework Version: 9.18.1
Release Notes: OnClose microflow update: - Added option to fire a microflow on websocket close, serverside - Reordered some parameters for consistency
Version: 1.0.0
Framework Version: 9.18.1
Release Notes: Initial release including: - Initialize websocket action - Notify action - Client listener widget