Skip to content

Commit

Permalink
chore(typings): add Messenger (#2688)
Browse files Browse the repository at this point in the history
  • Loading branch information
waitingsong authored and dead-horse committed Jun 13, 2018
1 parent f249cbe commit 73ca1b7
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ declare module 'egg' {
/**
* messenger instance
*/
messenger: any;
messenger: Messenger;

plugins: any;

Expand Down Expand Up @@ -1033,4 +1033,35 @@ declare module 'egg' {
? PowerPartial<T[U]>
: T[U]
};

// send data can be number|string|boolean|object but not Set|Map
export interface Messenger {
/**
* broadcast to all agent/app processes including itself
*/
broadcast(action: string, data: any): void;

/**
* send to agent from the app,
* send to an random app from the agent
*/
sendRandom(action: string, data: any): void;

/**
* send to specified process
*/
sendTo(pid: number, action: string, data: any): void;

/**
* send to agent from the app,
* send to itself from the agent
*/
sendToAgent(action: string, data: any): void;

/**
* send to all app including itself from the app,
* send to all app from the agent
*/
sendToApp(action: string, data: any): void;
}
}

0 comments on commit 73ca1b7

Please sign in to comment.