Predictu
Casino Integration

Real-Time Communication

The Predictu widget and your casino page communicate in real time through a structured, bidirectional messaging protocol. This keeps your casino shell perfectly synchronized with everything happening inside the prediction market experience — from balance changes to trade confirmations.

Two-way, real-time sync. Your casino page can send commands to the widget, and the widget sends events back to your page. Both directions are validated against your registered origins for security.

Bidirectional Communication

Messages flow in both directions between your casino page and the embedded Predictu widget. Each message type serves a specific purpose in keeping the two systems in sync.

Your Casino Page to the Widget

Your casino page initiates communication by sending commands to the widget:

ActionPurposeWhen to Use
Session initializationAuthenticate the player and set their starting balance inside the widgetAfter the widget loads on the page
Deposit notificationNotify the widget that the player has deposited funds through your cashierWhen a player deposits money via your casino's payment system
Withdrawal notificationNotify the widget that the player has withdrawn funds through your cashierWhen a player withdraws money via your casino's payment system

The Widget to Your Casino Page

The widget sends events back to your casino page whenever something meaningful happens:

EventPurposeWhat You Can Do With It
Ready signalThe widget is fully loaded, authenticated, and ready for interactionHide your loading skeleton and reveal the widget
Balance updateThe player's balance has changed (after a trade, settlement, or deposit)Update the balance display in your casino's header or wallet area
Trade confirmationA trade was successfully executedShow a notification, log analytics, or trigger animations in your casino shell
Navigation updateThe player navigated to a different section within the widgetSync your browser URL for deep linking, track page views in analytics, or adjust widget sizing

Session Lifecycle

The communication follows a predictable lifecycle:

1
Widget loads — The widget begins loading inside the iframe on your casino page.
2
Your page sends initialization — You provide the player's identity, current balance, and operator credentials. The widget uses this to authenticate the player and load your branded configuration.
3
Widget signals ready — Once authentication and branding are complete, the widget sends a ready signal. This is when you hide your loading state and let the player start interacting.
4
Ongoing synchronization — As the player trades, navigates, and interacts, the widget continuously sends events back to your page. You react to these events to keep your casino shell in sync.

Re-Initialization Support

You can re-send the initialization message at any time — for example, if your page reloads, if the player's balance changes from an external source, or if you need to switch player sessions. The widget gracefully re-authenticates and updates its state each time.

Origin Security

All communication is protected by origin validation on both sides:

  • Your side: Always verify that incoming messages originate from the Predictu widget before processing them.
  • Widget side: The widget validates every incoming message against your operator's registered origin whitelist. Messages from unregistered domains are silently ignored.
  • Outbound targeting: When the widget sends messages to your page, it targets your specific origin rather than broadcasting to all listeners.
Financial operations are server-verified. While the messaging layer provides convenient balance and trade events, all financial operations are verified server-side through the S2S protocol. The messaging layer is a synchronization convenience, not the source of truth for money movement.

Security Model

The communication protocol is designed with defense in depth:

ConcernProtection
Unauthorized messagesBoth sides validate message origins against registered whitelists before processing.
Balance manipulationBalance messages trigger server-side verification. The operator's wallet is always the source of truth.
ClickjackingThe widget sandbox prevents top-level navigation. All trades require explicit user confirmation within the widget.
Session hijackingPlayer identity is verified server-side during initialization. Client-side messages alone cannot establish a session.

Key Benefits

  • Instant synchronization — your casino shell always reflects the latest balance and activity.
  • Flexible integration — react to events in whatever way makes sense for your UI (notifications, animations, analytics, deep linking).
  • Secure by design — origin validation and server-side verification prevent unauthorized access.
  • Graceful re-initialization — supports page reloads, session switches, and external balance changes without disruption.