1 | import { JSONObject } from '@lumino/coreutils';
|
2 | import { DisposableDelegate } from '@lumino/disposable';
|
3 | import * as Kernel from './kernel';
|
4 | import * as KernelMessage from './messages';
|
5 |
|
6 |
|
7 |
|
8 | export declare class CommHandler extends DisposableDelegate implements Kernel.IComm {
|
9 | |
10 |
|
11 |
|
12 | constructor(target: string, id: string, kernel: Kernel.IKernelConnection, disposeCb: () => void);
|
13 | /**
|
14 | * The unique id for the comm channel.
|
15 | */
|
16 | get commId(): string;
|
17 | /**
|
18 | * The target name for the comm channel.
|
19 | */
|
20 | get targetName(): string;
|
21 | /**
|
22 | * Get the callback for a comm close event.
|
23 | *
|
24 | * #### Notes
|
25 | * This is called when the comm is closed from either the server or client.
|
26 | *
|
27 | * **See also:** [[ICommClose]], [[close]]
|
28 | */
|
29 | get onClose(): (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void>;
|
30 | /**
|
31 | * Set the callback for a comm close event.
|
32 | *
|
33 | * #### Notes
|
34 | * This is called when the comm is closed from either the server or client. If
|
35 | * the function returns a promise, and the kernel was closed from the server,
|
36 | * kernel message processing will pause until the returned promise is
|
37 | * fulfilled.
|
38 | *
|
39 | * **See also:** [[close]]
|
40 | */
|
41 | set onClose(cb: (msg: KernelMessage.ICommCloseMsg) => void | PromiseLike<void>);
|
42 | /**
|
43 | * Get the callback for a comm message received event.
|
44 | */
|
45 | get onMsg(): (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void>;
|
46 | /**
|
47 | * Set the callback for a comm message received event.
|
48 | *
|
49 | * #### Notes
|
50 | * This is called when a comm message is received. If the function returns a
|
51 | * promise, kernel message processing will pause until it is fulfilled.
|
52 | */
|
53 | set onMsg(cb: (msg: KernelMessage.ICommMsgMsg) => void | PromiseLike<void>);
|
54 | /**
|
55 | * Open a comm with optional data and metadata.
|
56 | *
|
57 | * #### Notes
|
58 | * This sends a `comm_open` message to the server.
|
59 | *
|
60 | * **See also:** [[ICommOpen]]
|
61 | */
|
62 | open(data?: JSONObject, metadata?: JSONObject, buffers?: (ArrayBuffer | ArrayBufferView)[]): Kernel.IShellFuture;
|
63 | /**
|
64 | * Send a `comm_msg` message to the kernel.
|
65 | *
|
66 | * #### Notes
|
67 | * This is a no-op if the comm has been closed.
|
68 | *
|
69 | * **See also:** [[ICommMsg]]
|
70 | */
|
71 | send(data: JSONObject, metadata?: JSONObject, buffers?: (ArrayBuffer | ArrayBufferView)[], disposeOnDone?: boolean): Kernel.IShellFuture;
|
72 | /**
|
73 | * Close the comm.
|
74 | *
|
75 | * #### Notes
|
76 | * This will send a `comm_close` message to the kernel, and call the
|
77 | * `onClose` callback if set.
|
78 | *
|
79 | * This is a no-op if the comm is already closed.
|
80 | *
|
81 | * **See also:** [[ICommClose]], [[onClose]]
|
82 | */
|
83 | close(data?: JSONObject, metadata?: JSONObject, buffers?: (ArrayBuffer | ArrayBufferView)[]): Kernel.IShellFuture;
|
84 | private _target;
|
85 | private _id;
|
86 | private _kernel;
|
87 | private _onClose;
|
88 | private _onMsg;
|
89 | }
|