Minor fixes
This commit is contained in:
@@ -3,6 +3,7 @@ import Job from "../Job/Job";
|
||||
import Logger from "../Logger";
|
||||
import PduProcessor from "../PDUProcessor/PduProcessor";
|
||||
import BindTranscieverReplyProcessor from "../PDUProcessor/Postprocessor/Center/BindTranscieverReplyProcessor";
|
||||
import DebugPduProcessor from "../PDUProcessor/Postprocessor/Center/DebugPduProcessor";
|
||||
import SubmitSmReplyProcessor from "../PDUProcessor/Postprocessor/Center/SubmitSmReplyProcessor";
|
||||
import ProcessorManager from "../PDUProcessor/ProcessorManager";
|
||||
import SmppSession from "../SmppSession";
|
||||
@@ -41,6 +42,7 @@ export default class Center extends SmppSession {
|
||||
|
||||
ProcessorManager.attachProcessor(this, ProcessorManager.getProcessor(SubmitSmReplyProcessor.name));
|
||||
ProcessorManager.attachProcessor(this, ProcessorManager.getProcessor(BindTranscieverReplyProcessor.name));
|
||||
ProcessorManager.attachProcessor(this, ProcessorManager.getProcessor(DebugPduProcessor.name));
|
||||
|
||||
this.logger = new Logger(`Center-${id}`);
|
||||
|
||||
|
@@ -26,7 +26,6 @@ export default class Client extends SmppSession {
|
||||
_password: string;
|
||||
_id: number;
|
||||
_status: string = this.STATUSES[0];
|
||||
pduProcessors: PduProcessor[] = [];
|
||||
readonly logger: Logger;
|
||||
private session?: any;
|
||||
private connectPromise: PersistentPromise | null = null;
|
||||
@@ -197,7 +196,7 @@ export default class Client extends SmppSession {
|
||||
}, this.eventSessionConnected.bind(this));
|
||||
this.session.on('error', this.eventSessionError.bind(this));
|
||||
this.session.on('close', this.eventSessionClose.bind(this));
|
||||
this.session.on('pdu', this.eventAnyPdu.bind(this));
|
||||
this.session.on('pdu', this.eventAnyPdu.bind(this, this.session));
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -11,7 +11,7 @@ const zlib = require("zlib");
|
||||
|
||||
const SERVER_PORT: number = Number(process.env.SERVER_PORT) || 8190;
|
||||
|
||||
export class HttpServer {
|
||||
export default class HttpServer {
|
||||
private readonly clientRequestHandler: RequestHandler;
|
||||
private readonly centerRequestHandler: RequestHandler;
|
||||
|
||||
|
@@ -8,7 +8,7 @@ export default class DebugPduProcessor extends Postprocessor {
|
||||
|
||||
processPdu(session: any, pdu: any, entity?: SmppSession | undefined): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
if (pdu.response) {
|
||||
if (!!pdu.command && pdu.command === "submit_sm") {
|
||||
session.send(pdu.response(), (replyPdu: any) => {
|
||||
resolve(replyPdu);
|
||||
});
|
||||
|
@@ -10,8 +10,8 @@ export default class EchoPduProcessor extends Postprocessor {
|
||||
|
||||
processPdu(session: any, pdu: any, entity?: SmppSession | undefined): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
let promises = [];
|
||||
if (pdu.response) {
|
||||
if (!!pdu.command && pdu.command === "submit_sm") {
|
||||
let promises = [];
|
||||
let replyPromise = session.send(pdu.response());
|
||||
let sendPromise = session.send(new smpp.PDU('deliver_sm', {
|
||||
source_addr: pdu.destination_addr,
|
||||
@@ -20,12 +20,12 @@ export default class EchoPduProcessor extends Postprocessor {
|
||||
}));
|
||||
promises.push(replyPromise);
|
||||
promises.push(sendPromise);
|
||||
Promise.all(promises).then((replyPdus: any) => {
|
||||
resolve(replyPdus);
|
||||
}).catch((error: any) => {
|
||||
reject(error);
|
||||
});
|
||||
}
|
||||
Promise.all(promises).then((replyPdus: any) => {
|
||||
resolve(replyPdus);
|
||||
}).catch((error: any) => {
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
@@ -186,6 +186,7 @@ export default abstract class SmppSession {
|
||||
eventAnyPdu(session: any, pdu: PDU): Promise<any> {
|
||||
if (!!pdu) {
|
||||
this.eventEmitter.emit(this.EVENT.ANY_PDU, pdu);
|
||||
// console.log("IS PDU TIME");
|
||||
this.logger.log6(pdu);
|
||||
this.processors.Postprocessor.forEach((processor: PduProcessor) => processor.processPdu(session, pdu, this));
|
||||
}
|
||||
|
11
src/main.ts
11
src/main.ts
@@ -1,6 +1,7 @@
|
||||
import CenterSessionManager from "./Center/CenterSessionManager";
|
||||
import Client from "./Client/Client";
|
||||
import ClientSessionManager from "./Client/ClientSessionManager";
|
||||
import HttpServer from "./HttpServer/HttpServer";
|
||||
import Logger from "./Logger";
|
||||
import ProcessorManager from "./PDUProcessor/ProcessorManager";
|
||||
import WSServer from "./WS/WSServer";
|
||||
@@ -12,9 +13,9 @@ let logger = new Logger("main");
|
||||
new ProcessorManager();
|
||||
let clientManager: ClientSessionManager = new ClientSessionManager();
|
||||
let centerManager: CenterSessionManager = new CenterSessionManager();
|
||||
let wss: WSServer = new WSServer([clientManager, centerManager]);
|
||||
|
||||
// let httpServer: HttpServer = new HttpServer(clientManager, centerManager);
|
||||
let wss: WSServer = new WSServer([clientManager, centerManager]);
|
||||
let httpServer: HttpServer = new HttpServer(clientManager, centerManager);
|
||||
|
||||
function cleanup(): void {
|
||||
logger.log1("Cleaning up...");
|
||||
@@ -39,9 +40,9 @@ async function main() {
|
||||
|
||||
// console.log(ProcessorManager.getProcessorsForType(Client.name));
|
||||
// ProcessorManager.attachProcessor(client, ProcessorManager.getProcessor(SourceEnumeratorProcessor.name));
|
||||
await client.doConnect();
|
||||
await client.doBind();
|
||||
client.sendMultipleDefault();
|
||||
// await client.doConnect();
|
||||
// await client.doBind();
|
||||
// client.sendMultipleDefault();
|
||||
console.log("OK");
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user