Introduction:
Player integration in sunbird-portal data exchange and telemetry log using window.postMessage()
and window.addEventListener()
Problem statement:
As per the web standards, the communication between iframe and window should be done via post messages.
Therefore
The player should emit all events using the iframe window.postMessage() API -
targetWindow.postMessage(message, targetOrigin, [transfer]);
The app/client integrating the player should listen for the player events using
window.addEventListener("message", ...);
The message data should be namespaced properly to identify the event source and data.
Telemetry should be redirected via the container
For Dispatching event: targetWindow.postMessage(message, targetOrigin, [transfer]);
For Listening event: window.addEventListener("message", (event) => { }, false);
Dispatch events list from portal to player:
Event name/Signature | Description | Data(Sender) |
---|---|---|
| Initialize player and player its self start | Player Config |
Listener events list from player to portal:
Event name/Signature | Description | Data(Receiver) |
---|---|---|
| For Logging assessment | Assess event object for Score |
| Where we can log | Telemetry object |
Going forward Player and Portal should use the same event signature for data exchange between Portal and Player