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
|
||||
client_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">
|
||||
<module name="smsgwtester" />
|
||||
<envs>
|
||||
<env name="LOG_LEVEL" value="4" />
|
||||
<env name="LOG_LEVEL" value="0" />
|
||||
</envs>
|
||||
<option name="interpreterRef" value="project" />
|
||||
<option name="enabledTsNodeEsmLoader" value="false" />
|
||||
|
@@ -7,6 +7,8 @@
|
||||
</scripts>
|
||||
<node-interpreter value="project" />
|
||||
<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>
|
||||
</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": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"pkg:windows": "pkg main.js --target node16-windows-x64 --output main.exe",
|
||||
"pkg:linux": "pkg main.js --target node16-linux-x64 --output main.exe"
|
||||
"tsc": "tsc",
|
||||
"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": [],
|
||||
"author": "",
|
||||
|
@@ -9,7 +9,7 @@ const bodyParser = require("body-parser");
|
||||
const compression = require("compression");
|
||||
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 {
|
||||
private readonly clientRequestHandler: RequestHandler;
|
||||
|
@@ -1,11 +1,8 @@
|
||||
// @ts-ignore
|
||||
import {WriteStream} from "fs";
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
// @ts-ignore
|
||||
const LOG_LEVEL: number = process.env.LOG_LEVEL || 6;
|
||||
// @ts-ignore
|
||||
const LOG_LEVEL: number = Number(process.env.LOG_LEVEL) || 0;
|
||||
const LOG_FILE: string = process.env.LOG_FILE || "";
|
||||
|
||||
export default class Logger {
|
||||
|
@@ -11,13 +11,11 @@ export default class EchoPduProcessor extends Postprocessor {
|
||||
processPdu(session: any, pdu: any, entity?: SmppSession | undefined): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
if (!!pdu.command && pdu.command === "submit_sm") {
|
||||
let sentPdu = new smpp.PDU('deliver_sm', {
|
||||
source_addr: pdu.destination_addr,
|
||||
destination_addr: pdu.source_addr,
|
||||
short_message: pdu.short_message
|
||||
});
|
||||
entity?.doSendPdu(sentPdu, session);
|
||||
resolve(sentPdu);
|
||||
let echoPdu = new smpp.PDU('deliver_sm', {...pdu});
|
||||
echoPdu.source_addr = pdu.destination_addr;
|
||||
echoPdu.destination_addr = pdu.source_addr;
|
||||
entity?.doSendPdu(echoPdu, session);
|
||||
resolve(echoPdu);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -115,11 +115,11 @@ export default abstract class SmppSession {
|
||||
|
||||
doSendPdu(pdu: PDU, session: any): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
let characterSizeBits: number = LongSmsProcessor.getCharacterSizeForEncoding(pdu);
|
||||
let maxMessageLength: number = LongSmsProcessor.maxMessageSizeBits / characterSizeBits;
|
||||
if (!!pdu.short_message && pdu.short_message.length > maxMessageLength) {
|
||||
pdu.short_message = pdu.short_message.substring(0, maxMessageLength);
|
||||
}
|
||||
// let characterSizeBits: number = LongSmsProcessor.getCharacterSizeForEncoding(pdu);
|
||||
// let maxMessageLength: number = LongSmsProcessor.maxMessageSizeBits / characterSizeBits;
|
||||
// if (!!pdu.short_message && pdu.short_message.length > maxMessageLength) {
|
||||
// pdu.short_message = pdu.short_message.substring(0, maxMessageLength);
|
||||
// }
|
||||
session.send(pdu, (reply: any) => resolve(reply));
|
||||
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 Client from "./Client/Client";
|
||||
import ClientSessionManager from "./Client/ClientSessionManager";
|
||||
import HttpServer from "./HttpServer/HttpServer";
|
||||
import Logger from "./Logger";
|
||||
import SourceEnumeratorProcessor from "./PDUProcessor/Preprocessor/Client/SourceEnumeratorProcessor";
|
||||
import ProcessorManager from "./PDUProcessor/ProcessorManager";
|
||||
import WSServer from "./WS/WSServer";
|
||||
|
||||
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 centerManager: CenterSessionManager = new CenterSessionManager();
|
||||
|
||||
@@ -25,31 +23,6 @@ function cleanup(): void {
|
||||
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('SIGINT', cleanup);
|
||||
process.on('SIGUSR1', cleanup);
|
||||
|
Reference in New Issue
Block a user