From 524c3994de0f3184b21cddda85f5e131a944cda2 Mon Sep 17 00:00:00 2001 From: xpeng <1216772231@qq.com> Date: Thu, 25 Aug 2022 00:22:41 +0200 Subject: [PATCH] fix pref_ip not working issue --- server.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server.js b/server.js index a30a5ef..7f2bdb2 100644 --- a/server.js +++ b/server.js @@ -14,10 +14,10 @@ var occupancy = [0, 0, 0, 0]; var suffixes = [11, 12, 13, 14]; var clients = {}; -function allocateClient(req) { +function allocateClient(msg) { var slot; - if (req.pref_ip) { - slot = suffixes.indexOf(req.pref_ip); + if (msg.pref_ip) { + slot = suffixes.indexOf(msg.pref_ip); if (slot >= 0 && !occupancy[slot]) { occupancy[slot] = 1; return slot; @@ -81,7 +81,7 @@ function registerUser(conn, req, msg) { } // Allocate User - var slot = allocateClient(req); + var slot = allocateClient(msg); var realip = req.socket.remoteAddress; if (slot < 0) { console.log('Dropping ' + realip + ' due to no party vacancy');