Options
All
  • Public
  • Public/Protected
  • All
Menu

The parent side of the connection.

Hierarchy

Index

Constructors

constructor

  • new ServerConnection(frame: HTMLIFrameElement, options?: any): ServerConnection

Properties

Private channel

channel: MessageChannel

connected

connected: boolean = false

Indicates if a connection has been established

Protected connectionStep

connectionStep: CONNECTION_STEPS = CONNECTION_STEPS.CONNECTION

Protected connectionTimeout

connectionTimeout: number

Protected frame

frame: HTMLIFrameElement

The iframe target to setup the connection on.

id

id: string | null

Protected messageListener

messageListener: any

Protected options

Protected port

port: MessagePort

Protected promises

promises: Promises

Methods

Protected clearConnectionTimeout

  • clearConnectionTimeout(): void

Private clientInitiation

  • clientInitiation(e: MessageEvent): void

close

  • close(): void
  • Close the port being used to communicate. It will prevent any further messages being sent or received.

    Returns void

Protected completeBacklog

  • completeBacklog(): void

emit

  • emit(event: string, payload?: any): this
  • This method will emit an event to its counterpart.

    Parameters

    • event: string

      The name of the event to emit.

    • Optional payload: any

      Payload to be sent with the event.

    Returns this

    Returns Connection instance.

Protected finishInit

  • finishInit(): void

Protected getRequestTimeout

  • getRequestTimeout(timeout: number | boolean | undefined): number | boolean

Protected handleError

  • handleError(error: any): void

Protected handleMessage

  • handleMessage(message: Message): void

init

  • init(): undefined | false
  • Used to trigger the initiation of a connection manually. To be used if the onload, and clientInitiates options are disabled.

    Returns undefined | false

Protected initPortEvents

  • initPortEvents(): void

Protected isClient

  • isClient(): Boolean

Private listenForHandshake

  • listenForHandshake(): void

Protected message

on

  • on(event: string, callback: Function): this
  • Bind a callback to an event.

    Parameters

    • event: string

      The name of the event to listen for.

    • callback: Function

      The function to call when the event is fired.

    Returns this

    Returns Connection instance.

request

  • request<T>(event: string, payload?: any, options?: RequestOptions): Promise<T>
  • Make a request of the counterpart. It will automatically reject the promise if the timeout time is exceeded.

    Type parameters

    • T

    Parameters

    • event: string

      The name of the event to emit

    • Optional payload: any

      Payload to be sent with the request

    • Default value options: RequestOptions = {}

    Returns Promise<T>

    A promise that can resolve with any payload

Private sendPortToClient

  • sendPortToClient(client: Window): void

Protected setConnectionTimeout

  • setConnectionTimeout(): void

Private setupChannel

  • setupChannel(): void

Private setupClientInit

  • setupClientInit(): void

Private setupLoadInit

  • setupLoadInit(): void

Protected uuidv4

  • uuidv4(): string

Object literals

Protected defaultOptions

defaultOptions: object

clientInitiates

clientInitiates: false = false

connectionTimeout

connectionTimeout: number = 2000

debug

debug: false = false

onload

onload: true = true

targetOrigin

targetOrigin: string = "*"

timeout

timeout: number = 200

window

window: Window = window

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc