import { JSONObject, JSONValue } from 'phosphor/lib/algorithm/json'; import { DisposableDelegate } from 'phosphor/lib/core/disposable'; import { IKernel, Kernel } from './kernel'; import { KernelMessage } from './messages'; /** * Comm channel handler. */ export declare class CommHandler extends DisposableDelegate implements Kernel.IComm { /** * Construct a new comm channel. */ constructor(target: string, id: string, kernel: IKernel, disposeCb: () => void); /** * The unique id for the comm channel. */ readonly commId: string; /** * The target name for the comm channel. */ readonly targetName: string; /** * Get the callback for a comm close event. * * #### Notes * This is called when the comm is closed from either the server or * client. * * **See also:** [[ICommClose]], [[close]] */ /** * Set the callback for a comm close event. * * #### Notes * This is called when the comm is closed from either the server or * client. * * **See also:** [[close]] */ onClose: (msg: KernelMessage.ICommCloseMsg) => void; /** * Get the callback for a comm message received event. */ /** * Set the callback for a comm message received event. */ onMsg: (msg: KernelMessage.ICommMsgMsg) => void; /** * Test whether the comm has been disposed. */ readonly isDisposed: boolean; /** * Open a comm with optional data and metadata. * * #### Notes * This sends a `comm_open` message to the server. * * **See also:** [[ICommOpen]] */ open(data?: JSONValue, metadata?: JSONObject): Kernel.IFuture; /** * Send a `comm_msg` message to the kernel. * * #### Notes * This is a no-op if the comm has been closed. * * **See also:** [[ICommMsg]] */ send(data: JSONValue, metadata?: JSONObject, buffers?: (ArrayBuffer | ArrayBufferView)[], disposeOnDone?: boolean): Kernel.IFuture; /** * Close the comm. * * #### Notes * This will send a `comm_close` message to the kernel, and call the * `onClose` callback if set. * * This is a no-op if the comm is already closed. * * **See also:** [[ICommClose]], [[onClose]] */ close(data?: JSONValue, metadata?: JSONObject): Kernel.IFuture; /** * Dispose of the resources held by the comm. */ dispose(): void; private _target; private _id; private _kernel; private _onClose; private _onMsg; }