UNPKG

theater-client

Version:

TypeScript client library for Theater actor system TCP protocol

65 lines 1.92 kB
/** * Channel stream implementation for real-time communication with Theater actors */ import { EventEmitter } from 'node:events'; import type { TheaterConnection } from '../connection/TheaterConnection.js'; import type { TheaterClient } from './TheaterClient.js'; import type { ChannelId } from '../types/protocol.js'; import type { ChannelStream, ChannelMessage } from '../types/client.js'; /** * Implementation of ChannelStream for real-time communication * Manages a long-lived connection for bidirectional messaging */ export declare class ChannelStreamImpl extends EventEmitter implements ChannelStream { readonly channelId: ChannelId; private connection; private client; private messageHandlers; private closeHandlers; private errorHandlers; private _isOpen; private messageLoopRunning; constructor(channelId: ChannelId, connection: TheaterConnection, client: TheaterClient); get isOpen(): boolean; /** * Start the continuous message listening loop */ private startMessageLoop; /** * Handle incoming responses from the connection */ private handleResponse; /** * Notify all message handlers of a new message */ private notifyMessageHandlers; /** * Handle channel close event */ private handleClose; /** * Handle error events */ private handleError; /** * Register a message handler */ onMessage(handler: (message: ChannelMessage) => void): () => void; /** * Register a close handler */ onClose(handler: () => void): () => void; /** * Register an error handler */ onError(handler: (error: Error) => void): () => void; /** * Send a message on this channel */ sendMessage(data: Uint8Array): Promise<void>; /** * Close the channel */ close(): void; } //# sourceMappingURL=ChannelStream.d.ts.map