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