new IframeBridgeClient()
- Description:
Client-seitige Bridge, die im iframe läuft. Kommuniziert mit dem Parent via window.parent.postMessage.
- Source:
Example
const bridge = new IframeBridgeClient({ sourceId: 'rotatebox-game' });
bridge.on('CONFIG:INIT', (config) => {
if (config.ui?.hideControls) hideToolbar();
if (config.runtime?.level) loadLevel(config.runtime.level);
});
bridge.on('INPUT:KEYBOARD', (payload) => {
if (payload.key === 'ArrowLeft') rotateLeft();
});
// Spielstatus nach oben melden
bridge.send('GAME:WON', { moves: 6 });
Members
_autoRelayPrefixes :Array.<string>
- Description:
Namespace-Prefixe für Auto-Relay an window.parent (3-Ebenen-Modell)
- Source:
Namespace-Prefixe für Auto-Relay an window.parent (3-Ebenen-Modell)
Type:
- Array.<string>
_boundMessageHandler :function|null
- Description:
Gebundener Message-Listener
- Source:
Gebundener Message-Listener
Type:
- function | null
_isInIframe :boolean
- Description:
Läuft in einem iframe?
- Source:
Läuft in einem iframe?
Type:
- boolean
_listeners :Map.<string, Set.<function()>>
- Description:
Event-Listener
- Source:
Event-Listener
Type:
- Map.<string, Set.<function()>>
acceptLegacy :boolean
- Source:
Type:
- boolean
clientType :string
- Source:
Type:
- string
config :Object
- Description:
Empfangene CONFIG:INIT-Daten
- Source:
Empfangene CONFIG:INIT-Daten
Type:
- Object
ready :boolean
- Description:
Ist die Bridge betriebsbereit?
- Source:
Ist die Bridge betriebsbereit?
Type:
- boolean
sourceId :string
- Source:
Type:
- string
targetOrigin :string
- Description:
Für lokale Entwicklung: '*'. Production: window.location.origin.
- Source:
Für lokale Entwicklung: '*'. Production: window.location.origin.
Type:
- string
Methods
destroy()
- Description:
Räumt alle Listener auf.
- Source:
off(type, callbackopt) → {IframeBridgeClient}
- Description:
Entfernt einen Event-Listener.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
type |
string | Message-Typ |
|
callback |
function |
<optional> |
Spezifischer Callback |
Returns:
this (für Chaining)
- Type
- IframeBridgeClient
on(type, callback) → {IframeBridgeClient}
- Description:
Registriert einen Event-Listener für einen Message-Typ.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
type |
string | Message-Typ oder Namespace-Prefix |
callback |
function | Callback(payload, fullMessage) |
Returns:
this (für Chaining)
- Type
- IframeBridgeClient
once(type, callback) → {IframeBridgeClient}
- Description:
Registriert einen einmaligen Event-Listener.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
type |
string | Message-Typ |
callback |
function | Callback(payload, fullMessage) |
Returns:
this (für Chaining)
- Type
- IframeBridgeClient
send(type, payloadopt)
- Description:
Sendet eine Message an den Parent. Im Standalone-Betrieb (kein iframe) wird die Message ignoriert.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
type |
string | Hierarchischer Typ (z.B. 'GAME:WON') |
||
payload |
Object |
<optional> |
{}
|
Datenobjekt |
sendReady()
- Description:
Sendet manuell das SYSTEM:READY-Signal. Normalerweise automatisch (autoReady=true).
- Source: