Skip to content

Commit

Permalink
Randomized port allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
codemakerai-dev committed Jul 9, 2024
1 parent e15211d commit 8263c7c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/assistant/assistantChatViewProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default class AssistantChatViewProvider implements vscode.WebviewViewProv
<script src="${mainScriptUrl}"></script>
<script>
window.speachEndpoint = "${this._speechServer.url()}";
window.speechEndpoint = "${this._speechServer.url()}";
window.resolveMediaFile = (fileName) => {
return "${mediaUrl}/" + fileName;
Expand Down
6 changes: 5 additions & 1 deletion src/assistant/speechServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default class SpeechServer {

private readonly host = 'localhost';

private port: number = 52020;
private port: number = this.allocatePort();

private server?: http.Server;

Expand Down Expand Up @@ -43,4 +43,8 @@ export default class SpeechServer {
url() {
return `http://${this.host}:${this.port}`;
}

private allocatePort() {
return 52000 + Math.ceil(Math.random() * 1000);
}
}
2 changes: 1 addition & 1 deletion webview/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function createMessageElement(sender, message) {
equalizerButtonElement.src = window.resolveMediaFile("pause.svg");

const input = encodeBase64url(message.message);
audio = new Audio(`${window.speachEndpoint}?input=${input}`);
audio = new Audio(`${window.speechEndpoint}?input=${input}`);
audio.autoplay = true;
['pause', 'error', 'ended'].forEach(event => {
audio.addEventListener(event, () => {
Expand Down

0 comments on commit 8263c7c

Please sign in to comment.