fix(cli): rename duplicate setStatus to setConnStatus in BrokerClient
The private setStatus(ConnStatus) conflicted with the public
setStatus("idle"|"working"|"dnd") method, causing TS2393 under strict
typecheck. Rename the private one to setConnStatus and update all
internal call sites.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -93,7 +93,7 @@ export class BrokerClient {
|
|||||||
/** Open WS, send hello, resolve when hello_ack received. */
|
/** Open WS, send hello, resolve when hello_ack received. */
|
||||||
async connect(): Promise<void> {
|
async connect(): Promise<void> {
|
||||||
if (this.closed) throw new Error("client is closed");
|
if (this.closed) throw new Error("client is closed");
|
||||||
this.setStatus("connecting");
|
this.setConnStatus("connecting");
|
||||||
const ws = new WebSocket(this.mesh.brokerUrl);
|
const ws = new WebSocket(this.mesh.brokerUrl);
|
||||||
this.ws = ws;
|
this.ws = ws;
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ export class BrokerClient {
|
|||||||
if (msg.type === "hello_ack") {
|
if (msg.type === "hello_ack") {
|
||||||
if (this.helloTimer) clearTimeout(this.helloTimer);
|
if (this.helloTimer) clearTimeout(this.helloTimer);
|
||||||
this.helloTimer = null;
|
this.helloTimer = null;
|
||||||
this.setStatus("open");
|
this.setConnStatus("open");
|
||||||
this.reconnectAttempt = 0;
|
this.reconnectAttempt = 0;
|
||||||
this.flushOutbound();
|
this.flushOutbound();
|
||||||
resolve();
|
resolve();
|
||||||
@@ -163,7 +163,7 @@ export class BrokerClient {
|
|||||||
reject(new Error("ws closed before hello_ack"));
|
reject(new Error("ws closed before hello_ack"));
|
||||||
}
|
}
|
||||||
if (!this.closed) this.scheduleReconnect();
|
if (!this.closed) this.scheduleReconnect();
|
||||||
else this.setStatus("closed");
|
else this.setConnStatus("closed");
|
||||||
};
|
};
|
||||||
|
|
||||||
const onError = (err: Error): void => {
|
const onError = (err: Error): void => {
|
||||||
@@ -277,7 +277,7 @@ export class BrokerClient {
|
|||||||
/* ignore */
|
/* ignore */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.setStatus("closed");
|
this.setConnStatus("closed");
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Internals ---
|
// --- Internals ---
|
||||||
@@ -373,7 +373,7 @@ export class BrokerClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private scheduleReconnect(): void {
|
private scheduleReconnect(): void {
|
||||||
this.setStatus("reconnecting");
|
this.setConnStatus("reconnecting");
|
||||||
const delay =
|
const delay =
|
||||||
BACKOFF_CAPS[Math.min(this.reconnectAttempt, BACKOFF_CAPS.length - 1)]!;
|
BACKOFF_CAPS[Math.min(this.reconnectAttempt, BACKOFF_CAPS.length - 1)]!;
|
||||||
this.reconnectAttempt += 1;
|
this.reconnectAttempt += 1;
|
||||||
@@ -388,7 +388,7 @@ export class BrokerClient {
|
|||||||
}, delay);
|
}, delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
private setStatus(s: ConnStatus): void {
|
private setConnStatus(s: ConnStatus): void {
|
||||||
if (this._status === s) return;
|
if (this._status === s) return;
|
||||||
this._status = s;
|
this._status = s;
|
||||||
this.opts.onStatusChange?.(s);
|
this.opts.onStatusChange?.(s);
|
||||||
|
|||||||
Reference in New Issue
Block a user