Minor fixes regarding websockets
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@
|
|||||||
node_modules
|
node_modules
|
||||||
package-lock.json
|
package-lock.json
|
||||||
sessions.json
|
sessions.json
|
||||||
|
client_sessions.json
|
||||||
|
23
main.js
23
main.js
@@ -516,10 +516,10 @@ class CenterSession {
|
|||||||
}
|
}
|
||||||
this.logger.log1(`Sending notify message from ${source} to ${destination} with message ${message}`);
|
this.logger.log1(`Sending notify message from ${source} to ${destination} with message ${message}`);
|
||||||
this.getNextSession().submit_sm({
|
this.getNextSession().submit_sm({
|
||||||
source_addr: source,
|
source_addr: source,
|
||||||
destination_addr: destination,
|
destination_addr: destination,
|
||||||
short_message: message
|
short_message: message
|
||||||
}, pdu => {
|
}, pdu => {
|
||||||
resolve(pdu);
|
resolve(pdu);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -1024,6 +1024,9 @@ class WSServer {
|
|||||||
delete this.clients[sessionId][index];
|
delete this.clients[sessionId][index];
|
||||||
}
|
}
|
||||||
this.clients[sessionId] = this.clients[sessionId].filter(Boolean);
|
this.clients[sessionId] = this.clients[sessionId].filter(Boolean);
|
||||||
|
if (this.clients[sessionId].length === 0) {
|
||||||
|
delete this.clients[sessionId];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1044,14 +1047,14 @@ class WSServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pduEvent(sessionId, pdu) {
|
pduEvent(sessionId, pdu) {
|
||||||
this.logger.log2(`Session with ID ${sessionId} fired PDU`);
|
|
||||||
let payload = {
|
|
||||||
type: 'pdu',
|
|
||||||
sessionId: sessionId,
|
|
||||||
value: pdu
|
|
||||||
}
|
|
||||||
let clients = this.clients[sessionId];
|
let clients = this.clients[sessionId];
|
||||||
if (!!clients) {
|
if (!!clients) {
|
||||||
|
this.logger.log2(`Session with ID ${sessionId} fired PDU`);
|
||||||
|
let payload = {
|
||||||
|
type: 'pdu',
|
||||||
|
sessionId: sessionId,
|
||||||
|
value: pdu
|
||||||
|
}
|
||||||
this.logger.log2(`Broadcasting session with ID ${sessionId} to ${clients.length} clients`);
|
this.logger.log2(`Broadcasting session with ID ${sessionId} to ${clients.length} clients`);
|
||||||
clients.forEach(client => {
|
clients.forEach(client => {
|
||||||
client.send(JSON.stringify(payload));
|
client.send(JSON.stringify(payload));
|
||||||
|
Reference in New Issue
Block a user