mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-01 00:42:49 +08:00
Add channel password prompt on mid-session join (fixes #3)
Joining a password-protected channel after connecting silently failed with only a generic error in the log - there was no way to enter a password except the initial-connect "default channel" field. - connector: "switch" now accepts an optional base64-encoded password and wires it through tsclientlib's existing set_password() API; a ChannelInvalidPassword failure is reported as a distinct channelPasswordRequired event instead of a generic error. - gateway: forwards channelPassword through switchChannel and remaps the connector's snake_case event to the frontend's camelCase shape. - web: new ChannelPasswordDialog prompts for the password (and flags a wrong retry); the password is cached in memory for the session so re-entering an already-unlocked channel doesn't prompt again, and the cache is cleared on disconnect. Also includes two earlier Pulse-theme CSS fixes (bottom-toolbar dropdowns opening off-screen; caret button height mismatch) and the Speaking Now bar / Pulse Phase D wiring from this session.
This commit is contained in:
1 parent
804fa44ab6
commit
27ac828641
6 files changed
+728
-22
No files matched your search
@@ -79,7 +79,7 @@ wss.on("connection", (socket: WebSocket) => {
|
||||
break;
|
||||
}
|
||||
case "switchChannel": {
|
||||
await connection?.switchChannel(msg.channelId);
|
||||
await connection?.switchChannel(msg.channelId, msg.channelPassword);
|
||||
break;
|
||||
}
|
||||
case "sendChatMessage": {
|
||||
|
||||
@@ -130,6 +130,7 @@ export type Ts3ConnectionEvent =
|
||||
| { type: "talkers"; clients: number[] }
|
||||
| { type: "disconnected"; reason: string }
|
||||
| { type: "error"; message: string }
|
||||
| { type: "channelPasswordRequired"; channelId: number }
|
||||
| ({ type: "serverLog" } & ServerLogEntry)
|
||||
| {
|
||||
type: "clientConnectionInfo";
|
||||
@@ -269,6 +270,7 @@ export class Ts3Connection {
|
||||
| { type: "talkers"; clients: number[] }
|
||||
| { type: "disconnected"; reason: string }
|
||||
| { type: "error"; message: string }
|
||||
| { type: "channelPasswordRequired"; channel_id: number }
|
||||
| ({ type: "serverLog" } & ServerLogEntry)
|
||||
| {
|
||||
type: "clientConnectionInfo";
|
||||
@@ -475,6 +477,8 @@ export class Ts3Connection {
|
||||
message: event.message,
|
||||
timestamp: event.timestamp,
|
||||
});
|
||||
} else if (event.type === "channelPasswordRequired") {
|
||||
this.emit({ type: "channelPasswordRequired", channelId: event.channel_id });
|
||||
} else {
|
||||
this.emit(event);
|
||||
}
|
||||
@@ -496,8 +500,11 @@ export class Ts3Connection {
|
||||
});
|
||||
}
|
||||
|
||||
async switchChannel(channelId: number): Promise<void> {
|
||||
this.child?.stdin.write(`switch ${channelId}\n`);
|
||||
async switchChannel(channelId: number, channelPassword?: string): Promise<void> {
|
||||
// The password travels base64-encoded on this line-based stdin protocol
|
||||
// so it can safely contain spaces or other characters.
|
||||
const passwordArg = channelPassword ? ` ${Buffer.from(channelPassword, "utf8").toString("base64")}` : "";
|
||||
this.child?.stdin.write(`switch ${channelId}${passwordArg}\n`);
|
||||
}
|
||||
|
||||
async getClientConnectionInfo(clientId: number): Promise<void> {
|
||||
|
||||
Reference in new issue
Block a user