Class DefaultMessageProvider

Implements the MessageProvider for WebView based devices that allow url interception and direct message evaluation (script injection). Messages are passed to device via HTTP GET and JSON encoded URLs. Messages are passed from device to browser from script evaluation via a known function which defaults to window.__dispatchMessage.

export
implements

MessageProvider

Hierarchy

  • DefaultMessageProvider

Implements

Index

Constructors

constructor

  • new DefaultMessageProvider(options?: undefined | { apiUrl?: undefined | string; dispatchFunc?: undefined | string; urlLengthLimit?: undefined | number }): DefaultMessageProvider
  • Initializes the message provider with the given options. In most cases, users should not have to supply their own options for these values.

    Parameters

    • Optional options: undefined | { apiUrl?: undefined | string; dispatchFunc?: undefined | string; urlLengthLimit?: undefined | number }

    Returns DefaultMessageProvider

Properties

Static DEFAULT_RATELIMIT_MAX_REQUEST_PER_SEC

DEFAULT_RATELIMIT_MAX_REQUEST_PER_SEC: number

Static HEADER_RATELIMIT_LIMIT

HEADER_RATELIMIT_LIMIT: string[]

Static HEADER_RATELIMIT_NEXTREQUEST

HEADER_RATELIMIT_NEXTREQUEST: string[]

Static HEADER_RATELIMIT_REMAINING

HEADER_RATELIMIT_REMAINING: string[]

Static HEADER_RATELIMIT_RESET

HEADER_RATELIMIT_RESET: string[]

Methods

receive

  • receive(callback: (message: Message<any>) => void): void
  • Register the callback for when events from the device are received.

    memberof

    DefaultMessageProvider

    Parameters

    • callback: (message: Message<any>) => void

      Function to be called whenever a message is received from the device. Function should take Message as a parameter to receive the contents of the message.

        • Parameters

          Returns void

    Returns void

send

  • Sends the command and payload to the device or service responsible for handling events.

    memberof

    DefaultMessageProvider

    Parameters

    • command: string

      Command name used to route events to the correct device or service handler.

    • Optional payload: any

      Data to be used with the command by the device or service.

    Returns Promise<MessageSendResponse>

    A promise that contains the send message result once resolved.

2019, Amazon.com, Inc. or its affiliates. All Rights Reserved.