Code polish

This commit is contained in:
David Majdandžić
2023-04-05 19:29:26 +02:00
parent 694124a6b7
commit 42493aab50
9 changed files with 18 additions and 15 deletions

View File

@@ -24,7 +24,7 @@ export default class CenterRequestHandler extends RequestHandler {
doGetAppliedProcessors(req: any, res: any): void {
this.sessionManager.getSession(req.params.id).then((session: SmppSession) => {
let processors: PduProcessor[] = session.pduProcessors;
let processors: PduProcessor[] = session.appliedProcessors;
res.send(processors.map((processor: any) => processor.serialize()));
}, this.handleSessionNotFound.bind(this, req, res));
}

View File

@@ -24,7 +24,7 @@ export default class ClientRequestHandler extends RequestHandler {
doGetAppliedProcessors(req: any, res: any): void {
this.sessionManager.getSession(req.params.id).then((session: SmppSession) => {
let processors: PduProcessor[] = session.pduProcessors;
let processors: PduProcessor[] = session.appliedProcessors;
res.send(processors.map((processor: any) => processor.serialize()));
}, this.handleSessionNotFound.bind(this, req, res));
}

View File

@@ -14,15 +14,6 @@ export default class Job {
this._count = count;
}
static pduParseShortMessage(pdu: PDU) {
if (pdu.short_message && pdu.short_message.type === "Buffer") {
pdu.short_message = Buffer.from(pdu.short_message.data, 'ascii').toString();
}
if (typeof pdu.short_message === "object") {
pdu.short_message = pdu.short_message.toString();
}
}
private _pdu: PDU;
get pdu(): PDU {
@@ -56,6 +47,15 @@ export default class Job {
this.eventEmitter.emit(Job.STATE_CHANGED, {});
}
static pduParseShortMessage(pdu: PDU) {
if (pdu.short_message && pdu.short_message.type === "Buffer") {
pdu.short_message = Buffer.from(pdu.short_message.data, 'ascii').toString();
}
if (typeof pdu.short_message === "object") {
pdu.short_message = pdu.short_message.toString();
}
}
static createEmptySingle(command: string): Job {
let pdu1 = new smpp.PDU(command, {});
Job.pduParseShortMessage(pdu1);

View File

@@ -1,5 +1,4 @@
import Center from "../../../Center/Center";
import SmppSession from "../../../SmppSession";
import Postprocessor from "../Postprocessor";
const smpp = require("smpp");

View File

@@ -3,6 +3,7 @@ import Preprocessor from "../Preprocessor";
export default class DestinationEnumeratorProcessor extends Preprocessor {
private iterator: number = 0;
constructor(type: string) {
super(type);
}

View File

@@ -3,6 +3,7 @@ import Preprocessor from "../Preprocessor";
export default class SourceEnumeratorProcessor extends Preprocessor {
private iterator: number = 0;
constructor(type: string) {
super(type);
}

View File

@@ -36,6 +36,10 @@ export default abstract class SmppSession {
this.processors[Postprocessor.name] = [];
}
get appliedProcessors(): PduProcessor[] {
return this.processors[Preprocessor.name].concat(this.processors[Postprocessor.name]);
}
abstract _username: string;
get username(): string {

View File

@@ -1,9 +1,7 @@
import Center from "./Center/Center";
import CenterSessionManager from "./Center/CenterSessionManager";
import Client from "./Client/Client";
import ClientSessionManager from "./Client/ClientSessionManager";
import Logger from "./Logger";
import SourceEnumeratorProcessor from "./PDUProcessor/Preprocessor/Client/SourceEnumeratorProcessor";
import ProcessorManager from "./PDUProcessor/ProcessorManager";
import WSServer from "./WS/WSServer";