Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RSDK-5228 - allow setting sdp values #181

16 changes: 11 additions & 5 deletions src/robot/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
}
Expand Down Expand Up @@ -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!');
Expand Down Expand Up @@ -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) {
purplenicole730 marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
8 changes: 6 additions & 2 deletions src/robot/dial.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ const dialDirect = async (conf: DialDirectConf): Promise<RobotClient> => {
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');
Expand Down Expand Up @@ -121,7 +121,11 @@ const dialWebRTC = async (conf: DialWebRTCConf): Promise<RobotClient> => {
if (conf.credential) {
creds = conf.credential;
}
await client.connect(conf.priority, conf.authEntity || impliedURL, creds);
await client.connect({
priority: conf.priority,
purplenicole730 marked this conversation as resolved.
Show resolved Hide resolved
authEntity: conf.authEntity || impliedURL,
creds: creds,
});

// eslint-disable-next-line no-console
console.debug('connected via WebRTC');
Expand Down
Loading