Use human-readable names for websockets

This commit is contained in:
Fedor Indutny 2021-12-01 19:55:17 +01:00 committed by GitHub
parent 27f4dc6177
commit 84407cb005
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 4 deletions

View file

@ -129,6 +129,7 @@ export class SocketManager extends EventListener {
this.setStatus(SocketStatus.CONNECTING);
const process = this.connectResource({
name: 'authenticated',
path: '/v1/websocket/',
query: { login: username, password },
resourceOptions: {
@ -253,6 +254,7 @@ export class SocketManager extends EventListener {
handler: IRequestHandler
): Promise<WebSocketResource> {
return this.connectResource({
name: 'provisioning',
path: '/v1/websocket/provisioning/',
resourceOptions: {
handleRequest: (req: IncomingWebSocketRequest): void => {
@ -426,6 +428,7 @@ export class SocketManager extends EventListener {
log.info('SocketManager: connecting unauthenticated socket');
const process = this.connectResource({
name: 'unauthenticated',
path: '/v1/websocket/',
resourceOptions: {
keepalive: { path: '/v1/keepalive' },
@ -464,10 +467,12 @@ export class SocketManager extends EventListener {
}
private connectResource({
name,
path,
resourceOptions,
query = {},
}: {
name: string;
path: string;
resourceOptions: WebSocketResourceOptions;
query?: Record<string, string>;
@ -481,6 +486,7 @@ export class SocketManager extends EventListener {
const url = `${this.options.url}${path}?${qs.encode(queryWithDefaults)}`;
return connectWebSocket({
name,
url,
certificateAuthority: this.options.certificateAuthority,
version: this.options.version,