Add event listener support to client
This commit is contained in:
@@ -201,6 +201,10 @@ export class Client implements SmppSession {
|
|||||||
this.setStatus(ClientStatus.BOUND);
|
this.setStatus(ClientStatus.BOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
on(event: string, callback: (...args: any[]) => void): void {
|
||||||
|
this.eventEmitter.on(event, callback);
|
||||||
|
}
|
||||||
|
|
||||||
private connectSession(): void {
|
private connectSession(): void {
|
||||||
if (!this.fieldsAreOk()) {
|
if (!this.fieldsAreOk()) {
|
||||||
return;
|
return;
|
||||||
|
@@ -4,7 +4,7 @@ export interface SmppSession {
|
|||||||
username: string,
|
username: string,
|
||||||
password: string,
|
password: string,
|
||||||
|
|
||||||
sendPdu(pdu: object): Promise<object>;
|
sendPdu(pdu: object, force?: boolean): Promise<object>;
|
||||||
|
|
||||||
sendSingle(job: Job): Promise<object>;
|
sendSingle(job: Job): Promise<object>;
|
||||||
|
|
||||||
|
@@ -32,7 +32,9 @@ client.connectAndBind().then(() => {
|
|||||||
source_addr: "1234567890",
|
source_addr: "1234567890",
|
||||||
destination_addr: "1234567890",
|
destination_addr: "1234567890",
|
||||||
short_message: "Hello World"
|
short_message: "Hello World"
|
||||||
}), 100, 100))
|
}), 100, 100));
|
||||||
|
|
||||||
|
client.on(Client.ClientEvents.ANY_PDU, (pdu: any) => console.log(pdu));
|
||||||
});
|
});
|
||||||
|
|
||||||
// class ClientSession {
|
// class ClientSession {
|
||||||
|
Reference in New Issue
Block a user