Real time events
Add real-time server-to-browser communication to your plugins via WebSockets or polling. Send notifications from PHP, receive events in JavaScript, no page reloads needed.
verified and archived by the registry · newer than the source platform's last reported tagDownload and compatibility
verification ledger
Source tagged by maintainer
github.com/marinaglancy/moodle-tool_realtime @ v2.1.2 · commit 63bc42ec67ce
Rebuilt deterministically from that tag
canonical ZIP, byte-identical on every rebuild
Artifact hash recorded in the public index
sha256 10edf4b7c7ec6c86728c09a6df3551545d2cb0e70f30eafa33e6834e3e21baa9
Release signed · trusted publishing
planned — TUF signing (RFC §4.3)
Recorded in public transparency log
planned — Sigstore/Rekor (RFC §4.3)
composer require marinaglancy/moodle-tool_realtime
About
Real time events is a framework for real-time communication between the server and the browser in Moodle plugins. Other plugins build on it, for example Kahoodle, a real-time quiz game.
- Server to browser: any PHP process, such as another user's request or a scheduled task,
calls
$channel->notify(). Every page subscribed to the channel receives the event in JavaScript throughcore/pubsub, without a page reload. - Browser to server: JavaScript sends data with
sendToServer(), and the request is passed to thePLUGINNAME_realtime_event_received()callback of your plugin. - Secure channels: subscription is only possible from PHP. The page receives a channel hash that authenticates the polling or websocket requests, so users cannot guess the channels of other contexts.
Backends
The communication method is provided by backend subplugins:
- PHP polling works on any Moodle site without additional software, with long or short polling.
- Centrifugo delivers events over WebSockets through Centrifugo, an open-source real-time messaging server that you run yourself. Its settings can be imported from a Railway template deployment or from the Centrifugo server configuration.
A test page measures the event latency and round-trip time with the enabled backend. See the README for the full API.