redweb 0.5.3 → 0.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "redweb",
3
- "version": "0.5.3",
3
+ "version": "0.5.5",
4
4
  "description": "A way to quickly set up an express server",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -66,6 +66,12 @@ class BaseSocketServer {
66
66
  handleConnection(socket, req) {
67
67
  const ip = req.socket.remoteAddress;
68
68
  console.log(`New client connected: ${ip}`);
69
+ if (this.clients.get(ip) !== undefined) {
70
+ const oldClient = this.clients.get(ip);
71
+ console.warn(`Client ${ip} already connected, disconnecting existing connection.`);
72
+ oldClient.send(JSON.stringify({msg: 'You are being disconnected because a new client is connected with your IP address.'}));
73
+ oldClient.close();
74
+ }
69
75
  this.clients.set(ip, socket);
70
76
  socket.isAssigned = false; // Tracks whether the socket has been assigned a handler.
71
77