Merge branch 'dev'
# Conflicts: # src/main.ts
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -4,3 +4,5 @@ package-lock.json
|
|||||||
sessions.json
|
sessions.json
|
||||||
client_sessions.json
|
client_sessions.json
|
||||||
center_sessions.json
|
center_sessions.json
|
||||||
|
dist
|
||||||
|
main.exe
|
||||||
|
@@ -1,5 +0,0 @@
|
|||||||
<component name="ProjectRunConfigurationManager">
|
|
||||||
<configuration default="false" name="main.js" type="NodeJSConfigurationType" nameIsGenerated="true" path-to-js-file="$PROJECT_DIR$/main.js" working-dir="$PROJECT_DIR$">
|
|
||||||
<method v="2" />
|
|
||||||
</configuration>
|
|
||||||
</component>
|
|
@@ -2,7 +2,7 @@
|
|||||||
<configuration default="false" name="main.ts" type="TypeScriptProgramRunner" factoryName="TypeScript">
|
<configuration default="false" name="main.ts" type="TypeScriptProgramRunner" factoryName="TypeScript">
|
||||||
<module name="smsgwtester" />
|
<module name="smsgwtester" />
|
||||||
<envs>
|
<envs>
|
||||||
<env name="LOG_LEVEL" value="4" />
|
<env name="LOG_LEVEL" value="0" />
|
||||||
</envs>
|
</envs>
|
||||||
<option name="interpreterRef" value="project" />
|
<option name="interpreterRef" value="project" />
|
||||||
<option name="enabledTsNodeEsmLoader" value="false" />
|
<option name="enabledTsNodeEsmLoader" value="false" />
|
||||||
|
@@ -7,6 +7,8 @@
|
|||||||
</scripts>
|
</scripts>
|
||||||
<node-interpreter value="project" />
|
<node-interpreter value="project" />
|
||||||
<envs />
|
<envs />
|
||||||
<method v="2" />
|
<method v="2">
|
||||||
|
<option name="RunConfigurationTask" enabled="true" run_configuration_name="tsc" run_configuration_type="js.build_tools.npm" />
|
||||||
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
</component>
|
</component>
|
12
.run/tsc.run.xml
Normal file
12
.run/tsc.run.xml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
<component name="ProjectRunConfigurationManager">
|
||||||
|
<configuration default="false" name="tsc" type="js.build_tools.npm" nameIsGenerated="true">
|
||||||
|
<package-json value="$PROJECT_DIR$/package.json" />
|
||||||
|
<command value="run" />
|
||||||
|
<scripts>
|
||||||
|
<script value="tsc" />
|
||||||
|
</scripts>
|
||||||
|
<node-interpreter value="project" />
|
||||||
|
<envs />
|
||||||
|
<method v="2" />
|
||||||
|
</configuration>
|
||||||
|
</component>
|
@@ -4,8 +4,9 @@
|
|||||||
"description": "",
|
"description": "",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"pkg:windows": "pkg main.js --target node16-windows-x64 --output main.exe",
|
"tsc": "tsc",
|
||||||
"pkg:linux": "pkg main.js --target node16-linux-x64 --output main.exe"
|
"pkg:windows": "pkg ./dist/main.js --target node16-windows-x64 --output main.exe",
|
||||||
|
"pkg:linux": "pkg ./dist/main.js --target node16-linux-x64 --output main.exe"
|
||||||
},
|
},
|
||||||
"keywords": [],
|
"keywords": [],
|
||||||
"author": "",
|
"author": "",
|
||||||
|
@@ -9,7 +9,7 @@ const bodyParser = require("body-parser");
|
|||||||
const compression = require("compression");
|
const compression = require("compression");
|
||||||
const zlib = require("zlib");
|
const zlib = require("zlib");
|
||||||
|
|
||||||
const SERVER_PORT: number = Number(process.env.SERVER_PORT) || 8190;
|
const SERVER_PORT: number = Number(process.env.SERVER_PORT) || 80;
|
||||||
|
|
||||||
export default class HttpServer {
|
export default class HttpServer {
|
||||||
private readonly clientRequestHandler: RequestHandler;
|
private readonly clientRequestHandler: RequestHandler;
|
||||||
|
@@ -1,11 +1,8 @@
|
|||||||
// @ts-ignore
|
|
||||||
import {WriteStream} from "fs";
|
import {WriteStream} from "fs";
|
||||||
|
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
|
||||||
// @ts-ignore
|
const LOG_LEVEL: number = Number(process.env.LOG_LEVEL) || 0;
|
||||||
const LOG_LEVEL: number = process.env.LOG_LEVEL || 6;
|
|
||||||
// @ts-ignore
|
|
||||||
const LOG_FILE: string = process.env.LOG_FILE || "";
|
const LOG_FILE: string = process.env.LOG_FILE || "";
|
||||||
|
|
||||||
export default class Logger {
|
export default class Logger {
|
||||||
|
@@ -11,13 +11,11 @@ export default class EchoPduProcessor extends Postprocessor {
|
|||||||
processPdu(session: any, pdu: any, entity?: SmppSession | undefined): Promise<any> {
|
processPdu(session: any, pdu: any, entity?: SmppSession | undefined): Promise<any> {
|
||||||
return new Promise<any>((resolve, reject) => {
|
return new Promise<any>((resolve, reject) => {
|
||||||
if (!!pdu.command && pdu.command === "submit_sm") {
|
if (!!pdu.command && pdu.command === "submit_sm") {
|
||||||
let sentPdu = new smpp.PDU('deliver_sm', {
|
let echoPdu = new smpp.PDU('deliver_sm', {...pdu});
|
||||||
source_addr: pdu.destination_addr,
|
echoPdu.source_addr = pdu.destination_addr;
|
||||||
destination_addr: pdu.source_addr,
|
echoPdu.destination_addr = pdu.source_addr;
|
||||||
short_message: pdu.short_message
|
entity?.doSendPdu(echoPdu, session);
|
||||||
});
|
resolve(echoPdu);
|
||||||
entity?.doSendPdu(sentPdu, session);
|
|
||||||
resolve(sentPdu);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@@ -115,11 +115,11 @@ export default abstract class SmppSession {
|
|||||||
|
|
||||||
doSendPdu(pdu: PDU, session: any): Promise<any> {
|
doSendPdu(pdu: PDU, session: any): Promise<any> {
|
||||||
return new Promise<any>((resolve, reject) => {
|
return new Promise<any>((resolve, reject) => {
|
||||||
let characterSizeBits: number = LongSmsProcessor.getCharacterSizeForEncoding(pdu);
|
// let characterSizeBits: number = LongSmsProcessor.getCharacterSizeForEncoding(pdu);
|
||||||
let maxMessageLength: number = LongSmsProcessor.maxMessageSizeBits / characterSizeBits;
|
// let maxMessageLength: number = LongSmsProcessor.maxMessageSizeBits / characterSizeBits;
|
||||||
if (!!pdu.short_message && pdu.short_message.length > maxMessageLength) {
|
// if (!!pdu.short_message && pdu.short_message.length > maxMessageLength) {
|
||||||
pdu.short_message = pdu.short_message.substring(0, maxMessageLength);
|
// pdu.short_message = pdu.short_message.substring(0, maxMessageLength);
|
||||||
}
|
// }
|
||||||
session.send(pdu, (reply: any) => resolve(reply));
|
session.send(pdu, (reply: any) => resolve(reply));
|
||||||
this.eventEmitter.emit(this.EVENT.ANY_PDU_TX, pdu);
|
this.eventEmitter.emit(this.EVENT.ANY_PDU_TX, pdu);
|
||||||
});
|
});
|
||||||
|
31
src/main.ts
31
src/main.ts
@@ -1,17 +1,15 @@
|
|||||||
import CenterSessionManager from "./Center/CenterSessionManager";
|
import CenterSessionManager from "./Center/CenterSessionManager";
|
||||||
import Client from "./Client/Client";
|
|
||||||
import ClientSessionManager from "./Client/ClientSessionManager";
|
import ClientSessionManager from "./Client/ClientSessionManager";
|
||||||
import HttpServer from "./HttpServer/HttpServer";
|
import HttpServer from "./HttpServer/HttpServer";
|
||||||
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";
|
||||||
|
|
||||||
const {PDU} = require("smpp");
|
const {PDU} = require("smpp");
|
||||||
|
|
||||||
let logger = new Logger("main");
|
let logger: Logger = new Logger("main");
|
||||||
|
|
||||||
new ProcessorManager();
|
let pm: ProcessorManager = new ProcessorManager();
|
||||||
let clientManager: ClientSessionManager = new ClientSessionManager();
|
let clientManager: ClientSessionManager = new ClientSessionManager();
|
||||||
let centerManager: CenterSessionManager = new CenterSessionManager();
|
let centerManager: CenterSessionManager = new CenterSessionManager();
|
||||||
|
|
||||||
@@ -25,31 +23,6 @@ function cleanup(): void {
|
|||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function main() {
|
|
||||||
let client: Client = await clientManager.getSession(0) as Client
|
|
||||||
// let center: Center = await centerManager.getSession(0) as Center;
|
|
||||||
// setInterval(async () => {
|
|
||||||
// await client.doConnect();
|
|
||||||
// setTimeout(async () => {
|
|
||||||
// await client.doBind();
|
|
||||||
// setTimeout(async () => {
|
|
||||||
// await center.close();
|
|
||||||
// }, 1000);
|
|
||||||
// }, 1000);
|
|
||||||
// }, 3000);
|
|
||||||
|
|
||||||
|
|
||||||
// console.log(ProcessorManager.getProcessorsForType(Client.name));
|
|
||||||
// ProcessorManager.attachProcessor(client, ProcessorManager.getProcessor(SourceEnumeratorProcessor.name));
|
|
||||||
// await client.doConnect();
|
|
||||||
// await client.doBind();
|
|
||||||
// client.sendMultipleDefault();
|
|
||||||
ProcessorManager.attachProcessor(client, ProcessorManager.getProcessor(SourceEnumeratorProcessor.name));
|
|
||||||
console.log("OK");
|
|
||||||
}
|
|
||||||
|
|
||||||
main();
|
|
||||||
|
|
||||||
process.on('exit', cleanup);
|
process.on('exit', cleanup);
|
||||||
process.on('SIGINT', cleanup);
|
process.on('SIGINT', cleanup);
|
||||||
process.on('SIGUSR1', cleanup);
|
process.on('SIGUSR1', cleanup);
|
||||||
|
Reference in New Issue
Block a user