Options
All
  • Public
  • Public/Protected
  • All
Menu

Used to abstract implementation details to allow for NodeJS and Browser usage of the library.

WebSocket Clover Interface. Abstracts the WebSocket implementation so that the library is not tied to a Browser implementation.

Interface to connect a websocket implementation to.

see

https://developer.mozilla.org/en-US/docs/Web/API/WebSocket or https://html.spec.whatwg.org/multipage/web-sockets.html

Hierarchy

Index

Constructors

constructor

Properties

Private endpoint

endpoint: string

Private listeners

listeners: Array<WebSocketListener>

Private logger

logger: Logger = Logger.create()

Private webSocket

webSocket: any

Methods

addListener

  • Parameters

    Returns void

connect

Abstract createWebSocket

  • createWebSocket(endpoint: string): any
  • For JS impls, we need to abstract out the WebSocket so that the library can be used in browsers and non-browsers.

    This MUST return immediately! It cannot use any type of promise or deferral, or the listener will not be properly attached before events begin firing.

    Parameters

    • endpoint: string

      the uri to connect to

    Returns any

getBufferedAmount

  • getBufferedAmount(): number
  • Returns number

getListeners

  • Returns Array<WebSocketListener>

getProtocol

  • getProtocol(): string
  • Returns string

getReadyState

  • Returns WebSocketState

getState

  • Returns WebSocketState

getUrl

  • getUrl(): String
  • Returns String

isOpen

  • isOpen(): boolean
  • Returns boolean

Private notifyOnClose

  • notifyOnClose(event: CloseEvent): void
  • Parameters

    • event: CloseEvent

    Returns void

Private notifyOnError

  • notifyOnError(event: any): void
  • A simple error event is passed per the websocket spec - https://www.w3.org/TR/websockets/#concept-websocket-close-fail It doesn't appear that an exact typing for the websocket error event is available, so I am using any.

    Parameters

    • event: any

      simple event passed per websocket spec.

    Returns void

Private notifyOnMessage

  • notifyOnMessage(event: MessageEvent): void
  • Parameters

    • event: MessageEvent

    Returns void

Private notifyOnOpen

  • notifyOnOpen(event: Event): void
  • Parameters

    • event: Event

    Returns void

removeListener

  • Parameters

    Returns boolean

sendClose

  • Parameters

    • Optional code: number
    • Optional reason: string

    Returns CloverWebSocketInterface

Abstract sendPing

  • Browser implementations do not do ping frames

    Returns CloverWebSocketInterface

Abstract sendPong

  • Browser implementations do not do pong frames

    Returns CloverWebSocketInterface

sendText

Generated using TypeDoc