Options
All
  • Public
  • Public/Protected
  • All
Menu

WebSocket Cloud Clover Transport. This handles the need to notify the device before a connection attempt is made.

Hierarchy

Implements

Index

Constructors

constructor

  • new WebSocketCloudCloverTransport(heartbeatInterval: number, reconnectDelay: number, retriesUntilDisconnect: number, webSocketImplClass: any, cloverServer: string, merchantId: string, accessToken: string, deviceId: string, friendlyId: string, forceConnect: boolean, httpSupport: HttpSupport): WebSocketCloudCloverTransport
  • Parameters

    • heartbeatInterval: number

      duration to wait for a PING before disconnecting

    • reconnectDelay: number

      duration to wait until a reconnect is attempted

    • retriesUntilDisconnect: number

      unused

    • webSocketImplClass: any

      the function that will return an instance of the CloverWebSocketInterface that will be used when connecting. For Browser implementations, this can be

    • cloverServer: string

      the base url for the clover server used in the cloud connection. EX: https://www.clover.com, http://localhost:9000

    • merchantId: string

      the merchant the device belongs to.

    • accessToken: string

      the OAuth access token that will be used when contacting the clover server

    • deviceId: string

      the id (not uuid) of the device to connect to

    • friendlyId: string

      an identifier for the specific terminal connected to this device. This id is used in debugging and may be sent to other clients if they attempt to connect to the same device. It will also be sent to other clients that are currently connected if this device does a forceConnect.

    • forceConnect: boolean

      if true, overtake any existing connection.

    • httpSupport: HttpSupport

      the helper object used when making http requests.

    Returns WebSocketCloudCloverTransport

Properties

Private accessToken

accessToken: string

Private cloverServer

cloverServer: string

Private deviceId

deviceId: string

Private forceConnect

forceConnect: boolean

Private friendlyId

friendlyId: string

Private httpSupport

httpSupport: HttpSupport

Protected logger

logger: Logger = Logger.create()

Private merchantId

merchantId: string

messageParser

messageParser: RemoteMessageParser

Protected objectMessageSender

objectMessageSender: ObjectMessageSender

Protected observers

observers: CloverTransportObserver[] = []

Protected ready

ready: Boolean = false

reconnector

reconnector: any = function() {if (!this.shutdown) {try {this.initialize();} catch (e) {this.reconnect();}}}.bind(this)

shutdown

shutdown: boolean = false

prevent reconnects if shutdown was requested

status

status: string = "Disconnected"

webSocket

webSocketImplClass

webSocketImplClass: any

This is the WebSocket implementation. This is odd, but it is how we can keep ourselves from being tied to a browser.

A NodeJS app that uses this library would pass in a different object than a browser implementation. NodeJS has an object that satisfies the requirements of the WebSocket (looks the same).

https://www.npmjs.com/package/websocket

Static METHOD

METHOD: string = "method"

Static PAYLOAD

PAYLOAD: string = "payload"

Static X_CLOVER_CONNECTED_ID

X_CLOVER_CONNECTED_ID: string = "X-CLOVER-CONNECTED-ID"

HTTP Header key that helps identify the connected client. Typically set to the 'friendlyId'.

type

{string}

Methods

Private afterOptionsCall

  • afterOptionsCall(deviceWebSocketEndpoint: string): void
  • Handles the response to the OPTIONS call. This helps with a 401 response, and is used to help identify any existing connection to the device.

    If the endpoint is available, then the transport is connected to the websocket.

    Parameters

    • deviceWebSocketEndpoint: string

    Returns void

clearListeners

  • clearListeners(): void

connectionError

Private deviceNotificationSent

  • deviceNotificationSent(notificationResponse: any): void
  • This handles the response from the server of the request to send a notification to the device. If the notification was successful, then an OPTIONS call is made using the information provided.

    Parameters

    • notificationResponse: any

      has a boolean property for 'sent', that indicates if the notification was sent to the device. If it was, then the properties 'host' and 'token' are used to derive the websocket endpoint uri.

    Returns void

dispose

  • dispose(): void

Private doOptionsCallToAvoid401Error

  • doOptionsCallToAvoid401Error(deviceWebSocketEndpoint: string): void

Protected initialize

  • initialize(): void

Protected initializeWithUri

  • initializeWithUri(deviceEndpoint: string): void

Protected notifyDeviceConnected

  • notifyDeviceConnected(): void

Protected notifyDeviceDisconnected

  • notifyDeviceDisconnected(): void

Protected notifyDeviceReady

  • notifyDeviceReady(): void

onClose

onMessage

onMessage_cwscl

onNotResponding

onOpen

onPingResponding

onSendError

  • onSendError(payloadText: string): void

reconnect

  • reconnect(): void

reset

  • reset(): void

sendMessage

  • sendMessage(message: string): number

setObjectMessageSender

subscribe

unsubscribe

Generated using TypeDoc