Cleanup code
This commit is contained in:
@@ -1,21 +1,20 @@
|
||||
import {PDU} from "../CommonObjects";
|
||||
import Logger from "../Logger";
|
||||
import SmppSession from "../SmppSession";
|
||||
|
||||
export default abstract class PduProcessor {
|
||||
readonly serverSessionType: string;
|
||||
readonly sessionType: string;
|
||||
readonly name: string = this.constructor.name;
|
||||
readonly logger: Logger = new Logger(`PduProcessor: ${this.name}`);
|
||||
|
||||
constructor(type: string) {
|
||||
this.serverSessionType = type;
|
||||
this.sessionType = type;
|
||||
}
|
||||
|
||||
abstract processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any>;
|
||||
|
||||
serialize(): object {
|
||||
return {
|
||||
servesSessionType: this.serverSessionType,
|
||||
servesSessionType: this.sessionType,
|
||||
name: this.name
|
||||
};
|
||||
}
|
||||
|
@@ -1,13 +1,9 @@
|
||||
import Center from "../../../Center/Center";
|
||||
import Client from "../../../Client/Client";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Postprocessor from "../Postprocessor";
|
||||
|
||||
export default class DebugPduProcessor extends Postprocessor {
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
|
@@ -1,6 +1,4 @@
|
||||
import Center from "../../../Center/Center";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Postprocessor from "../Postprocessor";
|
||||
|
||||
const smpp = require("smpp");
|
||||
@@ -8,7 +6,6 @@ const smpp = require("smpp");
|
||||
export default class EchoPduProcessor extends Postprocessor {
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
|
@@ -1,12 +1,9 @@
|
||||
import Client from "../../../Client/Client";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Postprocessor from "../Postprocessor";
|
||||
|
||||
export default class DeliverSmReplyProcessor extends Postprocessor {
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import PduProcessor from "../PduProcessor";
|
||||
|
||||
export default abstract class Postprocessor extends PduProcessor {
|
||||
readonly type: string = this.name;
|
||||
readonly type: string = Postprocessor.name;
|
||||
}
|
@@ -1,13 +1,10 @@
|
||||
import Client from "../../../Client/Client";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Preprocessor from "../Preprocessor";
|
||||
|
||||
export default class DestinationEnumeratorProcessor extends Preprocessor {
|
||||
private iterator: number = 0;
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
|
@@ -1,13 +1,10 @@
|
||||
import Client from "../../../Client/Client";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Preprocessor from "../Preprocessor";
|
||||
|
||||
export default class SourceEnumeratorProcessor extends Preprocessor {
|
||||
private iterator: number = 0;
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import PduProcessor from "../PduProcessor";
|
||||
|
||||
export default abstract class Preprocessor extends PduProcessor {
|
||||
readonly type: string = this.name;
|
||||
readonly type: string = Preprocessor.name;
|
||||
}
|
@@ -58,10 +58,10 @@ export default class ProcessorManager {
|
||||
|
||||
static areCompatible(session: SmppSession, processor: PduProcessor): boolean {
|
||||
this.logger.log1(`Checking compatibility between session ${session.constructor.name}-${session.id} and processor ${processor.name}`);
|
||||
return session.constructor.name === processor.serverSessionType;
|
||||
return session.constructor.name === processor.sessionType;
|
||||
}
|
||||
|
||||
static getProcessorsForType(type: string): PduProcessor[] {
|
||||
return this.processors.filter((processor: PduProcessor) => processor.serverSessionType === type);
|
||||
return this.processors.filter((processor: PduProcessor) => processor.sessionType === type);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user