Implement center operation modes
This commit is contained in:
33
main.js
33
main.js
@@ -439,6 +439,14 @@ class CenterSessionStatus {
|
|||||||
static CONNECTION_PENDING = "CONNECTION_PENDING";
|
static CONNECTION_PENDING = "CONNECTION_PENDING";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Implement endpoint for modifying modes
|
||||||
|
// TODO: Implement mode modification on centerSession
|
||||||
|
class CenterMode {
|
||||||
|
static DEBUG = "DEBUG";
|
||||||
|
static ECHO = "ECHO";
|
||||||
|
static DR = "DR";
|
||||||
|
}
|
||||||
|
|
||||||
class CenterSession {
|
class CenterSession {
|
||||||
// TODO: Currently this center behaves as a DEBUG server, Implement ECHO and DR functionality
|
// TODO: Currently this center behaves as a DEBUG server, Implement ECHO and DR functionality
|
||||||
// TODO: If the port is in use this throws an exception, catch it and log it
|
// TODO: If the port is in use this throws an exception, catch it and log it
|
||||||
@@ -447,6 +455,7 @@ class CenterSession {
|
|||||||
busy = false;
|
busy = false;
|
||||||
sessions = [];
|
sessions = [];
|
||||||
nextSession = 0;
|
nextSession = 0;
|
||||||
|
mode = CenterMode.DEBUG;
|
||||||
|
|
||||||
disconnectingPromise = {
|
disconnectingPromise = {
|
||||||
promise: null,
|
promise: null,
|
||||||
@@ -532,9 +541,15 @@ class CenterSession {
|
|||||||
}
|
}
|
||||||
|
|
||||||
sessionPdu(session, pdu) {
|
sessionPdu(session, pdu) {
|
||||||
// TODO: Implement ECHO and DR functionality
|
|
||||||
if (pdu.command === 'submit_sm') {
|
if (pdu.command === 'submit_sm') {
|
||||||
session.send(pdu.response());
|
session.send(pdu.response());
|
||||||
|
if (this.mode === CenterMode.ECHO) {
|
||||||
|
this.notify(pdu.source_addr, pdu.destination_addr, pdu.short_message);
|
||||||
|
}
|
||||||
|
// TODO: Figure out how DRs work
|
||||||
|
// if (this.mode === CenterMode.DR) {
|
||||||
|
// this.notify(pdu.source_addr, pdu.destination_addr, pdu.short_message);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
if (pdu.command === 'enquire_link') {
|
if (pdu.command === 'enquire_link') {
|
||||||
session.send(pdu.response());
|
session.send(pdu.response());
|
||||||
@@ -639,7 +654,8 @@ class CenterSession {
|
|||||||
username: this.username,
|
username: this.username,
|
||||||
password: this.password,
|
password: this.password,
|
||||||
status: this.status,
|
status: this.status,
|
||||||
activeSessions: this.sessions.length
|
activeSessions: this.sessions.length,
|
||||||
|
mode: this.mode
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1135,6 +1151,7 @@ centerSessionManager.startup();
|
|||||||
|
|
||||||
let session = clientSessionManager.getSession(0);
|
let session = clientSessionManager.getSession(0);
|
||||||
let server = centerSessionManager.getSession(0);
|
let server = centerSessionManager.getSession(0);
|
||||||
|
|
||||||
// session.connect()
|
// session.connect()
|
||||||
// .then(() => {
|
// .then(() => {
|
||||||
// session.bind().then(() => {
|
// session.bind().then(() => {
|
||||||
@@ -1149,12 +1166,12 @@ let server = centerSessionManager.getSession(0);
|
|||||||
// console.log(pdu);
|
// console.log(pdu);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
session.on(ClientSession.ANY_PDU_EVENT, (pdu) => {
|
// session.on(ClientSession.ANY_PDU_EVENT, (pdu) => {
|
||||||
if (pdu.command.includes('enquire')) {
|
// if (pdu.command.includes('enquire')) {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
console.log(pdu);
|
// console.log(pdu);
|
||||||
});
|
// });
|
||||||
|
|
||||||
new WSServer();
|
new WSServer();
|
||||||
new HTTPServer();
|
new HTTPServer();
|
||||||
|
Reference in New Issue
Block a user