feat(companion): add connection snapshot helper
This commit is contained in:
@@ -59,6 +59,15 @@ export interface EventSurfaceSnapshot {
|
||||
pendingEventWaitCount: number;
|
||||
}
|
||||
|
||||
export interface ConnectionSnapshot {
|
||||
connected: boolean;
|
||||
eventSubscriptionCount: number;
|
||||
pendingRequestCount: number;
|
||||
pendingEventWaitCount: number;
|
||||
hasPendingWork: boolean;
|
||||
idle: boolean;
|
||||
}
|
||||
|
||||
export type CompanionEventHandler = (event: string, data: unknown) => void;
|
||||
export type CompanionTypedEventHandler<TData = unknown> = (data: TData) => void;
|
||||
export type CompanionEventPredicate<TData = unknown> = (data: TData) => boolean;
|
||||
@@ -352,6 +361,17 @@ export class CompanionRuntimeClient {
|
||||
};
|
||||
}
|
||||
|
||||
getConnectionSnapshot(): ConnectionSnapshot {
|
||||
return {
|
||||
connected: this.connected,
|
||||
eventSubscriptionCount: this.eventSubscriptionCount,
|
||||
pendingRequestCount: this.pendingRequestCount,
|
||||
pendingEventWaitCount: this.pendingEventWaitCount,
|
||||
hasPendingWork: this.hasPendingWork,
|
||||
idle: this.idle,
|
||||
};
|
||||
}
|
||||
|
||||
async connect(): Promise<void> {
|
||||
if (this.connected) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user