| 1 | import type { EventEmitter } from 'node:events'; |
| 2 | |
| 3 | export interface IMessenger extends EventEmitter { |
| 4 | /** |
| 5 | * Send message to all agent and app |
| 6 | * @param {String} action - message key |
| 7 | * @param {Object} data - message value |
| 8 | * @return {Messenger} this |
| 9 | */ |
| 10 | broadcast(action: string, data?: unknown): IMessenger; |
| 11 | |
| 12 | /** |
| 13 | * send message to the specified process |
| 14 | * @param {String} workerId - the workerId of the receiver |
| 15 | * @param {String} action - message key |
| 16 | * @param {Object} data - message value |
| 17 | * @return {Messenger} this |
| 18 | */ |
| 19 | sendTo(workerId: string, action: string, data?: unknown): IMessenger; |
| 20 | |
| 21 | /** |
| 22 | * send message to one app worker by random |
| 23 | * - if it's running in agent, it will send to one of app workers |
| 24 | * - if it's running in app, it will send to agent |
| 25 | * @param {String} action - message key |
| 26 | * @param {Object} data - message value |
| 27 | * @return {Messenger} this |
| 28 | */ |
| 29 | sendRandom(action: string, data?: unknown): IMessenger; |
| 30 | |
| 31 | /** |
| 32 | * send message to app |
| 33 | * @param {String} action - message key |
| 34 | * @param {Object} data - message value |
| 35 | * @return {Messenger} this |
| 36 | */ |
| 37 | sendToApp(action: string, data?: unknown): IMessenger; |
| 38 | |
| 39 | /** |
| 40 | * send message to agent |
| 41 | * @param {String} action - message key |
| 42 | * @param {Object} data - message value |
| 43 | * @return {Messenger} this |
| 44 | */ |
| 45 | sendToAgent(action: string, data?: unknown): IMessenger; |
| 46 | |
| 47 | /** |
| 48 | * @param {String} action - message key |
| 49 | * @param {Object} data - message value |
| 50 | * @param {String} to - let master know how to send message |
| 51 | * @return {Messenger} this |
| 52 | */ |
| 53 | send(action: string, data: unknown | undefined, to?: string): IMessenger; |
| 54 | |
| 55 | close(): void; |
| 56 | |
| 57 | onMessage(message: any): void; |
| 58 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…