Minor fixes

This commit is contained in:
David Majdandžić
2023-03-26 17:12:32 +02:00
parent 5187854d5d
commit 8e5e1fcda3
3 changed files with 12 additions and 6 deletions

5
.run/main.js.run.xml Normal file
View File

@@ -0,0 +1,5 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="main.js" type="NodeJSConfigurationType" nameIsGenerated="true" path-to-js-file="main.js" working-dir="$PROJECT_DIR$">
<method v="2" />
</configuration>
</component>

11
main.js
View File

@@ -1505,6 +1505,7 @@ class WSServer {
onClientSessionPdu(sessionId, pdu) {
// TODO: Maybe move this to an "ignored" array against who the pdu.command is compared
// TODO: Figure out why the same client is getting the same pdu more than once
if (pdu.command === 'enquire_link_resp' || pdu.command === 'enquire_link') {
return;
}
@@ -1518,6 +1519,7 @@ class WSServer {
value: pdu
}
this.logger.log2(`Broadcasting session with ID ${sessionId} to ${clients.length} clients`);
console.log(clients);
clients.forEach(client => {
client.send(JSON.stringify(payload));
});
@@ -1672,8 +1674,7 @@ function cleanup() {
process.exit(0);
}
// process.on('exit', cleanup);
// process.on('SIGINT', cleanup);
// process.on('SIGUSR1', cleanup);
// process.on('SIGUSR2', cleanup);
// process.on('uncaughtException', cleanup);
process.on('exit', cleanup);
process.on('SIGINT', cleanup);
process.on('SIGUSR1', cleanup);
process.on('SIGUSR2', cleanup);

View File

@@ -6,7 +6,7 @@ const ws = new WebSocket(`ws://localhost:${WS_SERVER_PORT}`);
const ws2 = new WebSocket(`ws://localhost:${WS_SERVER_PORT}`);
ws.on('open', () => {
console.log('WebSocket connection established');
ws.send("client:0");
ws.send("client:1");
});
ws.on('message', (data) => {
console.log(String(data));