- this._ws = new WebSocket(
- `ws://${config.uiServer.host}:${config.uiServer.port}`,
- config.uiServer.protocol
- );
- this._ws.onmessage = this.responseHandler.bind(this);
- this._ws.onerror = (errorEvent) => {
- console.error('WebSocket error: ', errorEvent);
- };
- this._ws.onclose = (closeEvent) => {
- console.info('WebSocket closed: ', closeEvent);
- };
- }
-
- private setResponseHandler(
- id: string,
- procedureName: ProcedureName,
- resolve: (value: ResponsePayload | PromiseLike<ResponsePayload>) => void,
- reject: (reason?: any) => void
- ): void {
- this._responseHandlers.set(id, { procedureName, resolve, reject });
- }
-
- private getResponseHandler(id: string): ResponseHandler | undefined {
- return this._responseHandlers.get(id);
- }
-
- private deleteResponseHandler(id: string): boolean {
- return this._responseHandlers.delete(id);
+ const protocols =
+ this.configuration.uiServer.authentication?.enabled === true &&
+ this.configuration.uiServer.authentication?.type === AuthenticationType.PROTOCOL_BASIC_AUTH
+ ? [
+ `${this.configuration.uiServer.protocol}${this.configuration.uiServer.version}`,
+ `authorization.basic.${btoa(`${this.configuration.uiServer.authentication.username}:${this.configuration.uiServer.authentication.password}`).replace(/={1,2}$/, '')}`
+ ]
+ : `${this.configuration.uiServer.protocol}${this.configuration.uiServer.version}`
+ this.ws = new WebSocket(
+ `${this.configuration.uiServer.secure === true ? ApplicationProtocol.WSS : ApplicationProtocol.WS}://${this.configuration.uiServer.host}:${this.configuration.uiServer.port}`,
+ protocols
+ )
+ this.ws.onopen = openEvent => {
+ console.info('WebSocket opened', openEvent)
+ }
+ this.ws.onmessage = this.responseHandler.bind(this)
+ this.ws.onerror = errorEvent => {
+ console.error('WebSocket error: ', errorEvent)
+ }
+ this.ws.onclose = closeEvent => {
+ console.info('WebSocket closed: ', closeEvent)
+ }