wss on voice conditionally

This commit is contained in:
MathMan05
2025-12-09 15:57:02 -06:00
parent a8070e6294
commit 7cd39acbf6
2 changed files with 15 additions and 6 deletions
+9 -5
View File
@@ -322,11 +322,15 @@ class Localuser {
this.mdBox();
this.voiceFactory = new VoiceFactory({id: this.user.id}, (g) => {
if (this.ws) {
this.ws.send(JSON.stringify(g));
}
});
this.voiceFactory = new VoiceFactory(
{id: this.user.id},
(g) => {
if (this.ws) {
this.ws.send(JSON.stringify(g));
}
},
this.info.api.startsWith("https://"),
);
this.handleVoice();
this.mfa_enabled = ready.d.user.mfa_enabled as boolean;
this.userinfo.username = this.user.username;
+6 -1
View File
@@ -15,10 +15,13 @@ function forceVideo(video: HTMLVideoElement) {
class VoiceFactory {
settings: {id: string};
handleGateway: (obj: Object) => void;
secure: boolean;
constructor(
usersettings: VoiceFactory["settings"],
handleGateway: VoiceFactory["handleGateway"],
secure: boolean,
) {
this.secure = secure;
this.settings = usersettings;
this.handleGateway = handleGateway;
}
@@ -1312,7 +1315,9 @@ a=rtcp-mux\r`;
}
}
const ws = new WebSocket(("wss://" + this.urlobj.url) as string);
const ws = new WebSocket(
((this.owner.secure ? "wss://" : "ws://") + this.urlobj.url) as string,
);
this.ws = ws;
ws.onclose = () => {
this.leave();