Add event listener support to client

This commit is contained in:
David Majdandžić
2023-03-28 03:15:44 +02:00
parent f0c1cae0e0
commit 1dd5b9ed7c
3 changed files with 8 additions and 2 deletions

View File

@@ -201,6 +201,10 @@ export class Client implements SmppSession {
this.setStatus(ClientStatus.BOUND);
}
on(event: string, callback: (...args: any[]) => void): void {
this.eventEmitter.on(event, callback);
}
private connectSession(): void {
if (!this.fieldsAreOk()) {
return;

View File

@@ -4,7 +4,7 @@ export interface SmppSession {
username: string,
password: string,
sendPdu(pdu: object): Promise<object>;
sendPdu(pdu: object, force?: boolean): Promise<object>;
sendSingle(job: Job): Promise<object>;

View File

@@ -32,7 +32,9 @@ client.connectAndBind().then(() => {
source_addr: "1234567890",
destination_addr: "1234567890",
short_message: "Hello World"
}), 100, 100))
}), 100, 100));
client.on(Client.ClientEvents.ANY_PDU, (pdu: any) => console.log(pdu));
});
// class ClientSession {