import { JSONObject, JSONValue } from '@phosphor/coreutils'; import { DisposableDelegate } from '@phosphor/disposable'; import { 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: 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. If * the function returns a promise, and the kernel was closed from the server, * kernel message processing will pause until the returned promise is * fulfilled. * * **See also:** [[close]] */ onClose: (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike; /** * Get the callback for a comm message received event. */ /** * Set the callback for a comm message received event. * * #### Notes * This is called when a comm message is received. If the function returns a * promise, kernel message processing will pause until it is fulfilled. */ onMsg: (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike; /** * 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, buffers?: (ArrayBuffer | ArrayBufferView)[]): 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, buffers?: (ArrayBuffer | ArrayBufferView)[]): Kernel.IFuture; private _target; private _id; private _kernel; private _onClose; private _onMsg; }