Code polish

This commit is contained in:
David Majdandžić
2023-04-06 21:03:59 +02:00
parent 12896b2a5b
commit e913934ed9
5 changed files with 27 additions and 26 deletions

View File

@@ -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;
}
}