Web SDK - StreamEvents

Home > @rainway/web > StreamEvents

StreamEvents interface

Signature:

export interface StreamEvents 

Properties

PropertyModifiersTypeDescription
"before-input"(input: RainwayInputEvent) => void | Promise<void>

Raised when an input (keyboard, mouse, gamepad...) is about to be sent to the remote device.

Only input attempts enabled by the stream's InputLevel cause beforeinput events.

You can listen to this event and call event.preventDefault() to apply a fine-grained input filter, or respond to key combinations. Example:

myStream.addEventListener("beforeinput", (event) => {
    const { input, heldKeys } = event;
    if (input.type === "keyboard" && input.key === VirtualKey.Q) {
        // Block the input, but send a message instead.
        event.preventDefault();
        if (input.action === KeyboardAction.Down) {
            myStream.host.send(makeCoolRequest());
        }
    }
});

This should not be used to prevent security-sensitive key combinations like Alt+Tab. Instead, the remote host can filter \_incoming\_ inputs. See https://docs.rainway.com/docs/input-filtering for more info.

| | [close](./web-sdk-streamevents-close) | | () => void \| Promise<void> | Raised when the remote closes the stream. | | [stats](./web-sdk-streamevents-stats) | | (stats: [StatsSummary](./web-sdk-statssummary)) => void \| Promise<void> | Raised periodically during the stream, and provides various statistics about stream performance. |