Implement source and desination enumerators for client

This commit is contained in:
David Majdandžić
2023-04-04 09:49:44 +02:00
parent e2a7c52541
commit c498f6cfb7
9 changed files with 119 additions and 47 deletions

View File

@@ -0,0 +1,20 @@
import {Client} from "../../Client/Client";
import {PDU} from "../../CommonObjects";
import {PduProcessor} from "../PduProcessor";
export class DestinationEnumeratorProcessor extends PduProcessor {
serverSessionType: string = Client.name;
private iterator = 0;
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
return new Promise<any>((resolve, reject) => {
if (!!pdu.destination_addr) {
pdu.destination_addr = pdu.destination_addr + this.padLeft(String(this.iterator++), '0', 5);
}
});
}
private padLeft(str: string, pad: string, length: number): string {
return (new Array(length + 1).join(pad) + str).slice(-length);
}
}

View File

@@ -0,0 +1,20 @@
import {Client} from "../../Client/Client";
import {PDU} from "../../CommonObjects";
import {PduProcessor} from "../PduProcessor";
export class SourceEnumeratorProcessor extends PduProcessor {
serverSessionType: string = Client.name;
private iterator = 0;
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
return new Promise<any>((resolve, reject) => {
if (!!pdu.source_addr) {
pdu.source_addr = pdu.source_addr + this.padLeft(String(this.iterator++), '0', 5);
}
});
}
private padLeft(str: string, pad: string, length: number): string {
return (new Array(length + 1).join(pad) + str).slice(-length);
}
}

View File

@@ -12,6 +12,6 @@ export class DebugPduProcessor extends PduProcessor {
resolve(replyPdu);
});
}
})
});
}
}