WebSocket Scripting  —  Mouse Demonstration
Clients: [closed]

Description [+]

This example illustrates the fine granularity of the asynchronous, bi-directional network channel provided by a WebSocket.

To begin, move the mouse over the [closed] indicator. A WebSocket connection will be established with the server-side application (script). This application handles multiple, concurrent clients. Your connection has the host:port underlined. The mouse position of all connected clients is displayed to each client. With each mouse movement on the page the cursor position is sent to the application where it updates that client's status. With each client update all connected clients have the revised mouse position display updated. To help manage potential bandwidth consumption the update rate is explicitly limited at both client and server.

If left unused the WebSocket is disconnected by the server-side application and can be restarted by moving the mouse over the [disconnected] indicator.

This demonstration is JavaScript-driven at the browser end

WASD_ROOT:[SRC.WEBSOCKET]WS_MOUSE.HTML

and uses a WebSocket protocol application (script) at the WASD server end

WASD_ROOT:[SRC.WEBSOCKET]WS_MOUSE.C

All of these interactions can be observed using the WASD WATCH facility; [x]CGI, [x]DCL and [x]Network Data items.

Configuration [+]

The script is a native WebSocket protocol application and so the executable should only need placing in the script directory.

To effectively display multiple clients the script must rely on there being only a single instance of it executing (a particular issue when employing multiple WASD instances). Generally the server will only need to instantiate a single WS_MOUSE script to handle multiple clients, however there is a small window when the client request is being accepted by the script where it is unavailable.

Suppress host name lookup by defining the logical name WS_MOUSE_NO_LOOKUP.