routing/src/implementableApi.ts
2021-05-23 16:07:23 +02:00

31 lines
814 B
TypeScript

import EventEmitter from "events";
namespace ImplementableApi {
export type Config = {
name: string;
}
/**
* [optional] idListener is the way to identificate the listener who's the src of the newEntries
* the type field permit to know which type of message it is
* rawContent field is the string content of the message
*/
export type Message = {
idListener?: number;
type: "newEntriesNotify" | "newListener";
rawContent: any;
}
}
abstract class ImplementableApi extends EventEmitter {
readonly name: string;
constructor(readonly config: ImplementableApi.Config) {
super();
this.name = config.name;
}
public abstract receivedMessage(message: ImplementableApi.Message): void;
}
export { ImplementableApi }