mirror of
https://github.com/Moepchi/webspeak3.git
synced 2026-12-03 09:52:50 +08:00
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e7add6dc8 | ||
|
|
983ce1e105 |
No files matched your search
@@ -1148,6 +1148,10 @@ async fn run(args: Args) -> Result<()> {
|
||||
loop {
|
||||
let mut events = con.events();
|
||||
let outcome = tokio::select! {
|
||||
// After a stall (e.g. CPU steal) the missed audio ticks fire in a burst.
|
||||
// Polling in order drains the queued packets first, otherwise a tick can
|
||||
// find an empty queue and play Opus loss concealment instead.
|
||||
biased;
|
||||
line = stdin_lines.next_line() => LoopOutcome::StdinLine(line),
|
||||
ev = events.next() => LoopOutcome::ConEvent(ev),
|
||||
_ = audio_ticker.tick() => LoopOutcome::AudioTick,
|
||||
|
||||
+16
-2
@@ -8000,14 +8000,17 @@ function AppInner() {
|
||||
// detach and run the drop handling right away.
|
||||
socket.onmessage = socket.onerror = socket.onclose = null;
|
||||
socket.close();
|
||||
logClient("warning", "Connection", `No keepalive from the gateway for ${KEEPALIVE_TIMEOUT_MS / 1000} s`);
|
||||
current().onclose();
|
||||
}, KEEPALIVE_TIMEOUT_MS);
|
||||
}
|
||||
if (event.data !== KEEPALIVE_MESSAGE) current().onmessage(event);
|
||||
};
|
||||
socket.onerror = () => current().onerror();
|
||||
socket.onclose = () => {
|
||||
socket.onclose = (event) => {
|
||||
clearTimeout(watchdog);
|
||||
// 1000/1001 are clean closes; 1006 means the link died without a close frame.
|
||||
logClient("info", "Connection", `Gateway connection closed (code ${event.code ?? "?"})`);
|
||||
current().onclose();
|
||||
};
|
||||
};
|
||||
@@ -8113,7 +8116,7 @@ function AppInner() {
|
||||
// network blip, or the page coming back from being backgrounded/suspended
|
||||
// — without disturbing which tab is active or losing chat/scroll history.
|
||||
const reconnectSession = (sessionId: string) => {
|
||||
const params = sessionParamsRef.current.get(sessionId);
|
||||
let params = sessionParamsRef.current.get(sessionId);
|
||||
const rec = sessionsRef.current.get(sessionId);
|
||||
if (!params || !rec) return;
|
||||
// Already open or mid-(re)connect — nothing to do.
|
||||
@@ -8121,6 +8124,17 @@ function AppInner() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Come back in the channel we were in, like the native client does. Kept
|
||||
// in the params so a failed attempt (empty client list) still aims there.
|
||||
const isActive = sessionId === activeSessionIdRef.current;
|
||||
const state = isActive ? { clients, ownClientId } : rec.parked;
|
||||
const lastChannel = state?.clients.find((c) => c.id === state.ownClientId)?.channel;
|
||||
if (lastChannel) {
|
||||
const cachedPassword = isActive ? channelPasswordCacheRef.current.get(lastChannel) : undefined;
|
||||
params = { ...params, defaultChannel: `/${lastChannel}`, channelPassword: cachedPassword ?? params.channelPassword };
|
||||
sessionParamsRef.current.set(sessionId, params);
|
||||
}
|
||||
|
||||
logClient("info", "Connection", `Reconnecting to ${params.host}…`);
|
||||
const socket = DEMO_MODE ? new DemoSocket() : new WebSocket(GATEWAY_URL);
|
||||
rec.socket = socket;
|
||||
|
||||
Reference in new issue
Block a user