Member Junction
    Preparing search index...

    Interface IRealtimeRelayPolicy

    The provider half of MJAPI's realtime relay: what the relay needs to know about one provider's wire protocol. The relay (MJServer) owns the transport (sockets, deadlines, pings, the frame cap, close codes) and calls the policy at five points. A policy lives with its provider driver, so MJServer depends on this interface only.

    Client frames are text: the relay drops binary client frames before the policy sees them, and every frame a policy returns goes upstream as text. Server frames reach ObserveServerFrame as bytes and go to the browser unchanged.

    interface IRealtimeRelayPolicy {
        FilterClientFrame(frame: string): RealtimeRelayFrameVerdict;
        ObserveServerFrame(data: Uint8Array, isBinary: boolean): string;
        OpeningFrames(intent: RealtimeRelayOpenIntent): string[];
        ReadOpenIntent(firstClientFrame: string): RealtimeRelayOpenIntent;
        UpstreamHeaders(): Promise<Record<string, string>>;
    }

    Implemented by

    Index

    Methods

    • Sees each server frame before the relay forwards it unchanged, and returns the new resumption handle the frame carries, else null. Called for every frame (avatar video included), so it should check cheaply before parsing.

      Parameters

      • data: Uint8Array
      • isBinary: boolean

      Returns string

    • Headers for the upstream handshake (for example Authorization: Bearer <token>). Called on every upstream open, so a short-lived token is fresh for each connection. Never logged and never sent to the browser.

      Returns Promise<Record<string, string>>