Code polish
This commit is contained in:
@@ -73,7 +73,8 @@ export default class Client extends SmppSession {
|
||||
super.defaultMultipleJob = job;
|
||||
}
|
||||
|
||||
destroy(): void {}
|
||||
destroy(): void {
|
||||
}
|
||||
|
||||
doConnect(): PersistentPromise {
|
||||
this.connectPromise = new PersistentPromise((resolve, reject) => {
|
||||
|
@@ -1,7 +1,7 @@
|
||||
import {PDU} from "./CommonObjects";
|
||||
|
||||
export default class MessageIdManager {
|
||||
private static messages: {[key: string]: number} = {};
|
||||
private static messages: { [key: string]: number } = {};
|
||||
|
||||
static addMessageId(message: PDU, id: number): void {
|
||||
this.messages[this.getMessageHash(message)] = id;
|
||||
|
@@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@@ -5,8 +5,8 @@ import Preprocessor from "../Preprocessor";
|
||||
const smpp = require('smpp');
|
||||
|
||||
export default class LongSmsProcessor extends Preprocessor {
|
||||
private iterator: number = 0;
|
||||
static readonly maxMessageSizeBits = 1072;
|
||||
private iterator: number = 0;
|
||||
|
||||
constructor(type: string) {
|
||||
// An sms can have a maximum length (short_message) of 1120 bits or 140 bytes.
|
||||
@@ -29,6 +29,24 @@ export default class LongSmsProcessor extends Preprocessor {
|
||||
super(type);
|
||||
}
|
||||
|
||||
static getCharacterSizeForEncoding(pdu: PDU) {
|
||||
let encoding: number | undefined = pdu.data_coding;
|
||||
if (!encoding) {
|
||||
encoding = 0;
|
||||
}
|
||||
let characterSizeBits: number = 0;
|
||||
switch (encoding) {
|
||||
case 0:
|
||||
case 1:
|
||||
characterSizeBits = 8;
|
||||
break;
|
||||
case 8:
|
||||
characterSizeBits = 16;
|
||||
break;
|
||||
}
|
||||
return characterSizeBits;
|
||||
}
|
||||
|
||||
processPdu(session: any, pdu: PDU, entity?: SmppSession | undefined): Promise<any> {
|
||||
return new Promise<any>((resolve, reject) => {
|
||||
if (!!pdu.short_message) {
|
||||
@@ -65,22 +83,4 @@ export default class LongSmsProcessor extends Preprocessor {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static getCharacterSizeForEncoding(pdu: PDU) {
|
||||
let encoding: number | undefined = pdu.data_coding;
|
||||
if (!encoding) {
|
||||
encoding = 0;
|
||||
}
|
||||
let characterSizeBits: number = 0;
|
||||
switch (encoding) {
|
||||
case 0:
|
||||
case 1:
|
||||
characterSizeBits = 8;
|
||||
break;
|
||||
case 8:
|
||||
characterSizeBits = 16;
|
||||
break;
|
||||
}
|
||||
return characterSizeBits;
|
||||
}
|
||||
}
|
@@ -26,10 +26,10 @@ export default class ProcessorManager {
|
||||
// Try running eb22a43 to find out what's wrong with the previous approach
|
||||
ProcessorManager.postprocessors = [
|
||||
new EnquireLinkReplyProcessor(Center.name),
|
||||
new EchoPduProcessor(Center.name),
|
||||
new DeliverSmReplyProcessor(Client.name),
|
||||
new SubmitSmReplyProcessor(Center.name),
|
||||
new BindTranscieverReplyProcessor(Center.name),
|
||||
new EchoPduProcessor(Center.name),
|
||||
new DeliveryReceiptProcessor(Center.name)
|
||||
];
|
||||
ProcessorManager.preprocessors = [
|
||||
|
@@ -50,7 +50,7 @@ async function main() {
|
||||
|
||||
main();
|
||||
|
||||
// process.on('exit', cleanup);
|
||||
// process.on('SIGINT', cleanup);
|
||||
// process.on('SIGUSR1', cleanup);
|
||||
// process.on('SIGUSR2', cleanup);
|
||||
process.on('exit', cleanup);
|
||||
process.on('SIGINT', cleanup);
|
||||
process.on('SIGUSR1', cleanup);
|
||||
process.on('SIGUSR2', cleanup);
|
Reference in New Issue
Block a user