Options
All
  • Public
  • Public/Protected
  • All
Menu

Class SessionPort

Provides two-way communication between two SessionPort instances.

Hierarchy

  • SessionPort

Index

Constructors

constructor

Properties

Private _connectEvent

_connectEvent: Event<undefined> = new Event<undefined>()

Private _info

Private _isClosed

_isClosed: boolean = false

Private _isConnected

_isConnected: boolean = false

Private _isOpened

_isOpened: boolean = false

Private _version

_version: number[] = []

closeEvent

closeEvent: Event<undefined> = new Event<undefined>()

An event which fires when this port has closed

errorEvent

errorEvent: Event<Error> = new Event<Error>()

An error which fires when an error occurs.

messagePort

messagePort: MessagePortLike

The message port used to post and receive messages.

on

A map from topic to message handler.

suppressErrorOnUnknownTopic

suppressErrorOnUnknownTopic: boolean = false

If true, don't raise an error when receiving a message for an unknown topic

Optional uri

uri: string

Static CLOSE

CLOSE: string = "ar.session.close"

Static ERROR

ERROR: string = "ar.session.error"

Static OPEN

OPEN: string = "ar.session.open"

Accessors

connectEvent

  • get connectEvent(): Event<undefined>

info

isClosed

  • get isClosed(): boolean

isConnected

  • get isConnected(): boolean

version

  • get version(): Array<number>
  • The version of argon.js which is used by the connecting session. This property is an empty array until the session connects.

    Returns Array<number>

Methods

close

  • close(): void

open

request

  • Send a request and return a promise for the result.

    Parameters

    • topic: string

      the message topic.

    • Optional message: Message

      the message to be sent.

    Returns Promise<void | Message>

    if the session is not opened or is closed, return a rejected promise, Otherwise, the returned promise is resolved or rejected based on the response.

send

  • send(topic: string, message?: void | Message): boolean
  • Send a message

    Parameters

    • topic: string

      the message topic.

    • Optional message: void | Message

      the message to be sent.

    Returns boolean

    Return true if the message is posted successfully, return false if the session is closed.

sendError

  • Send an error message.

    Parameters

    Returns boolean

    Return true if the error message is sent successfully, otherwise, return false.

supportsProtocol

  • supportsProtocol(name: string, versions?: number | number[]): boolean
  • Check if a protocol is supported by this session.

    Parameters

    • name: string
    • Optional versions: number | number[]

    Returns boolean

whenConnected

  • whenConnected(): Promise<void>

Generated using TypeDoc