Finally make the stupid pre/post processors work
This commit is contained in:
@@ -1,11 +1,16 @@
|
||||
import {PDU} from "../CommonObjects";
|
||||
import Logger from "../Logger";
|
||||
import SmppSession from "../SmppSession";
|
||||
|
||||
export default abstract class PduProcessor {
|
||||
abstract readonly serverSessionType: string;
|
||||
readonly serverSessionType: string;
|
||||
readonly name: string = this.constructor.name;
|
||||
readonly logger: Logger = new Logger(`PduProcessor: ${this.name}`);
|
||||
|
||||
constructor(type: string) {
|
||||
this.serverSessionType = type;
|
||||
}
|
||||
|
||||
abstract processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any>;
|
||||
|
||||
serialize(): object {
|
||||
|
||||
@@ -1,9 +1,14 @@
|
||||
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 {
|
||||
serverSessionType: string = Center.name;
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
import Center from "../../../Center/Center";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Postprocessor from "../Postprocessor";
|
||||
|
||||
const smpp = require("smpp");
|
||||
|
||||
export default class EchoPduProcessor extends Postprocessor {
|
||||
serverSessionType: string = Center.name;
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
import Client from "../../../Client/Client";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Postprocessor from "../Postprocessor";
|
||||
|
||||
export default class DeliverSmReplyProcessor extends Postprocessor {
|
||||
serverSessionType: string = Client.name;
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import Client from "../../../Client/Client";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Preprocessor from "../Preprocessor";
|
||||
|
||||
export default class DestinationEnumeratorProcessor extends Preprocessor {
|
||||
serverSessionType: string = Client.name;
|
||||
private iterator = 0;
|
||||
private iterator: number = 0;
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
import Client from "../../../Client/Client";
|
||||
import {PDU} from "../../../CommonObjects";
|
||||
import SmppSession from "../../../SmppSession";
|
||||
import Preprocessor from "../Preprocessor";
|
||||
|
||||
export default class SourceEnumeratorProcessor extends Preprocessor {
|
||||
serverSessionType: string = Client.name;
|
||||
private iterator = 0;
|
||||
private iterator: number = 0;
|
||||
constructor(type: string) {
|
||||
super(type);
|
||||
console.log(this.serverSessionType);
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, ...args: any[]): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import Center from "../Center/Center";
|
||||
import Client from "../Client/Client";
|
||||
import Logger from "../Logger";
|
||||
import SmppSession from "../SmppSession";
|
||||
import PduProcessor from "./PduProcessor";
|
||||
@@ -8,18 +10,22 @@ import DestinationEnumeratorProcessor from "./Preprocessor/Client/DestinationEnu
|
||||
import SourceEnumeratorProcessor from "./Preprocessor/Client/SourceEnumeratorProcessor";
|
||||
|
||||
export default class ProcessorManager {
|
||||
static readonly preprocessors: PduProcessor[] = [
|
||||
new DestinationEnumeratorProcessor(),
|
||||
new SourceEnumeratorProcessor()
|
||||
];
|
||||
static readonly postprocessors: PduProcessor[] = [
|
||||
new DebugPduProcessor(),
|
||||
new EchoPduProcessor(),
|
||||
new DeliverSmReplyProcessor(),
|
||||
];
|
||||
static preprocessors: PduProcessor[];
|
||||
static postprocessors: PduProcessor[];
|
||||
private static readonly logger: Logger = new Logger(this.name);
|
||||
|
||||
constructor() {
|
||||
// This is an IDIOTIC solution, but it works
|
||||
// Try running eb22a43 to find out what's wrong with the previous approach
|
||||
ProcessorManager.preprocessors = [
|
||||
new DestinationEnumeratorProcessor(Client.name),
|
||||
new SourceEnumeratorProcessor(Client.name)
|
||||
];
|
||||
ProcessorManager.postprocessors = [
|
||||
new DebugPduProcessor(Center.name),
|
||||
new EchoPduProcessor(Center.name),
|
||||
new DeliverSmReplyProcessor(Center.name),
|
||||
];
|
||||
}
|
||||
|
||||
static get processors(): PduProcessor[] {
|
||||
|
||||
Reference in New Issue
Block a user