UNPKG

camstreamerlib

Version:

Helper library for CamStreamer ACAP applications.

25 lines (24 loc) 834 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CamOverlayEvents = void 0; const WsEvents_1 = require("../internal/WsEvents"); const CamOverlayEvents_1 = require("../types/ws/CamOverlayEvents"); class CamOverlayEvents extends WsEvents_1.WsEvents { getAuthToken; constructor(ws, getAuthToken) { super(CamOverlayEvents_1.coEventsSchema, ws); this.getAuthToken = getAuthToken; this.ws.onOpen = this.sendInitMsg; } sendInitMsg = async () => { try { const token = await this.getAuthToken(); this.ws.send(JSON.stringify({ authorization: token })); } catch (error) { console.error('Error on open:', error); this.ws.reconnect(); } }; } exports.CamOverlayEvents = CamOverlayEvents;