Class: Server

Server

A JSON-RPC 2.0 server that handles requests and notifications over window.postMessage.

Constructor

new Server(handlers, defaultHandleropt)

Constructs a Server instance.

Parameters:
Name Type Attributes Description
handlers object

The object whose methods will be exposed over JSON-RPC. Each method may return either a Promise, a plain value, or nothing at all.

defaultHandler MessageEventHandler <optional>

This callback is invoked when a message event cannot be routed to a handler. If this is omitted, unroutable messages will cause exceptions to be thrown.

Source:

Methods

mount(window)

Start listening for message events.

Parameters:
Name Type Description
window Window

The browser window to which a handler will be attached.

Source:

unmount(window)

Stop listening for message events.

Parameters:
Name Type Description
window Window

The browser window from which the handler will be detached.

Source: