From 0269ef3557e01f92ec3179b9f91de391fff42029 Mon Sep 17 00:00:00 2001 From: purplenicole730 Date: Wed, 25 Oct 2023 15:30:29 -0400 Subject: [PATCH] call connect with options --- src/robot/client.ts | 16 +++++++++++----- src/robot/dial.ts | 8 ++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/robot/client.ts b/src/robot/client.ts index e849aaf8b..2138c8fa4 100644 --- a/src/robot/client.ts +++ b/src/robot/client.ts @@ -55,6 +55,12 @@ interface SessionOptions { disabled: boolean; } +export interface ConnectOptions { + priority?: number; + authEntity?: string; + creds?: Credentials; +} + abstract class ServiceClient { constructor(public serviceHost: string, public options?: grpc.RpcOptions) {} } @@ -164,7 +170,7 @@ export class RobotClient extends EventDispatcher implements Robot { console.debug('connection closed, will try to reconnect'); void backOff( () => - this.connect().then( + this.connect({}).then( () => { // eslint-disable-next-line no-console console.debug('reconnected successfully!'); @@ -369,11 +375,11 @@ export class RobotClient extends EventDispatcher implements Robot { return this.peerConn?.iceConnectionState === 'connected'; } - public async connect( - priority?: number, + public async connect({ + priority, authEntity = this.savedAuthEntity, - creds = this.savedCreds - ) { + creds = this.savedCreds, + }: ConnectOptions) { if (this.connecting) { // This lint is clearly wrong due to how the event loop works such that after an await, the condition may no longer be true. // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition diff --git a/src/robot/dial.ts b/src/robot/dial.ts index be9143fbc..a740dc4ca 100644 --- a/src/robot/dial.ts +++ b/src/robot/dial.ts @@ -58,7 +58,7 @@ const dialDirect = async (conf: DialDirectConf): Promise => { if (conf.credential) { creds = conf.credential; } - await client.connect(undefined, conf.authEntity, creds); + await client.connect({ authEntity: conf.authEntity, creds: creds }); // eslint-disable-next-line no-console console.debug('connected via gRPC'); @@ -121,7 +121,11 @@ const dialWebRTC = async (conf: DialWebRTCConf): Promise => { if (conf.credential) { creds = conf.credential; } - await client.connect(conf.priority, conf.authEntity || impliedURL, creds); + await client.connect({ + priority: conf.priority, + authEntity: conf.authEntity || impliedURL, + creds: creds, + }); // eslint-disable-next-line no-console console.debug('connected via WebRTC');