Code polish
This commit is contained in:
@@ -24,7 +24,7 @@ export default class CenterRequestHandler extends RequestHandler {
|
|||||||
|
|
||||||
doGetAppliedProcessors(req: any, res: any): void {
|
doGetAppliedProcessors(req: any, res: any): void {
|
||||||
this.sessionManager.getSession(req.params.id).then((session: SmppSession) => {
|
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()));
|
res.send(processors.map((processor: any) => processor.serialize()));
|
||||||
}, this.handleSessionNotFound.bind(this, req, res));
|
}, this.handleSessionNotFound.bind(this, req, res));
|
||||||
}
|
}
|
||||||
|
@@ -24,7 +24,7 @@ export default class ClientRequestHandler extends RequestHandler {
|
|||||||
|
|
||||||
doGetAppliedProcessors(req: any, res: any): void {
|
doGetAppliedProcessors(req: any, res: any): void {
|
||||||
this.sessionManager.getSession(req.params.id).then((session: SmppSession) => {
|
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()));
|
res.send(processors.map((processor: any) => processor.serialize()));
|
||||||
}, this.handleSessionNotFound.bind(this, req, res));
|
}, this.handleSessionNotFound.bind(this, req, res));
|
||||||
}
|
}
|
||||||
|
@@ -14,15 +14,6 @@ export default class Job {
|
|||||||
this._count = count;
|
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;
|
private _pdu: PDU;
|
||||||
|
|
||||||
get pdu(): PDU {
|
get pdu(): PDU {
|
||||||
@@ -56,6 +47,15 @@ export default class Job {
|
|||||||
this.eventEmitter.emit(Job.STATE_CHANGED, {});
|
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 {
|
static createEmptySingle(command: string): Job {
|
||||||
let pdu1 = new smpp.PDU(command, {});
|
let pdu1 = new smpp.PDU(command, {});
|
||||||
Job.pduParseShortMessage(pdu1);
|
Job.pduParseShortMessage(pdu1);
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
import Center from "../../../Center/Center";
|
import Center from "../../../Center/Center";
|
||||||
import SmppSession from "../../../SmppSession";
|
|
||||||
import Postprocessor from "../Postprocessor";
|
import Postprocessor from "../Postprocessor";
|
||||||
|
|
||||||
const smpp = require("smpp");
|
const smpp = require("smpp");
|
||||||
|
@@ -3,6 +3,7 @@ import Preprocessor from "../Preprocessor";
|
|||||||
|
|
||||||
export default class DestinationEnumeratorProcessor extends Preprocessor {
|
export default class DestinationEnumeratorProcessor extends Preprocessor {
|
||||||
private iterator: number = 0;
|
private iterator: number = 0;
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
@@ -3,6 +3,7 @@ import Preprocessor from "../Preprocessor";
|
|||||||
|
|
||||||
export default class SourceEnumeratorProcessor extends Preprocessor {
|
export default class SourceEnumeratorProcessor extends Preprocessor {
|
||||||
private iterator: number = 0;
|
private iterator: number = 0;
|
||||||
|
|
||||||
constructor(type: string) {
|
constructor(type: string) {
|
||||||
super(type);
|
super(type);
|
||||||
}
|
}
|
||||||
|
@@ -36,6 +36,10 @@ export default abstract class SmppSession {
|
|||||||
this.processors[Postprocessor.name] = [];
|
this.processors[Postprocessor.name] = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get appliedProcessors(): PduProcessor[] {
|
||||||
|
return this.processors[Preprocessor.name].concat(this.processors[Postprocessor.name]);
|
||||||
|
}
|
||||||
|
|
||||||
abstract _username: string;
|
abstract _username: string;
|
||||||
|
|
||||||
get username(): string {
|
get username(): string {
|
||||||
|
@@ -1,9 +1,7 @@
|
|||||||
import Center from "./Center/Center";
|
|
||||||
import CenterSessionManager from "./Center/CenterSessionManager";
|
import CenterSessionManager from "./Center/CenterSessionManager";
|
||||||
import Client from "./Client/Client";
|
import Client from "./Client/Client";
|
||||||
import ClientSessionManager from "./Client/ClientSessionManager";
|
import ClientSessionManager from "./Client/ClientSessionManager";
|
||||||
import Logger from "./Logger";
|
import Logger from "./Logger";
|
||||||
import SourceEnumeratorProcessor from "./PDUProcessor/Preprocessor/Client/SourceEnumeratorProcessor";
|
|
||||||
import ProcessorManager from "./PDUProcessor/ProcessorManager";
|
import ProcessorManager from "./PDUProcessor/ProcessorManager";
|
||||||
import WSServer from "./WS/WSServer";
|
import WSServer from "./WS/WSServer";
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user