Skip to content

Commit

Permalink
fix: store session options
Browse files Browse the repository at this point in the history
  • Loading branch information
OrKoN authored and Lightning00Blade committed Aug 1, 2024
1 parent 1cd977e commit b873713
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/bidiServer/WebSocketServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ type Session = {
type SessionOptions = {
readonly chromeOptions: ChromeOptions;
readonly verbose: boolean;
readonly sessionNewBody: string;
};

export class WebSocketServer {
Expand Down Expand Up @@ -138,6 +139,7 @@ export class WebSocketServer {
sessionOptions: {
chromeOptions: this.#getChromeOptions(jsonBody.capabilities),
verbose: this.#verbose,
sessionNewBody: `{"id":0,"method":"session.new","params":${body.toString()}}`,
},
};
this.#sessions.set(sessionId, session);
Expand Down Expand Up @@ -297,6 +299,7 @@ export class WebSocketServer {
parsedCommandData.params?.capabilities
),
verbose: this.#verbose,
sessionNewBody: plainCommandData,
};

const browserInstance = await this.#launchBrowserInstance(
Expand All @@ -322,9 +325,6 @@ export class WebSocketServer {
);
return;
}

const browserInstance = await session.browserInstancePromise;
await browserInstance!.bidiSession().sendCommand(plainCommandData);
return;
}

Expand Down Expand Up @@ -454,7 +454,12 @@ export class WebSocketServer {
this.#sendClientMessageString(message, connection);
});

await browserInstance
.bidiSession()
.sendCommand(sessionOptions.sessionNewBody);

debugInfo('Browser is launched!');

return browserInstance;
}

Expand Down

0 comments on commit b873713

Please sign in to comment.