From ff8b7f20813ffd50ea61cc2d406ecbe129d5610c Mon Sep 17 00:00:00 2001 From: Mann Patel <130435633+MannPatel0@users.noreply.github.com> Date: Sun, 30 Mar 2025 00:27:40 -0600 Subject: [PATCH] Delete client.js --- recommondation-engine/client.js | 48 --------------------------------- 1 file changed, 48 deletions(-) delete mode 100644 recommondation-engine/client.js diff --git a/recommondation-engine/client.js b/recommondation-engine/client.js deleted file mode 100644 index 67258ae..0000000 --- a/recommondation-engine/client.js +++ /dev/null @@ -1,48 +0,0 @@ -const net = require("net"); - -// Function to get recommendations from the Python server -function getRecommendations(userId) { - const client = new net.Socket(); - - // Connect to the server on localhost at port 9999 - client.connect(9999, "localhost", function () { - console.log(`Connected to server, sending user_id: ${userId}`); - - // Send the user_id in JSON format - const message = JSON.stringify({ user_id: userId }); - client.write(message); - }); - - // Listen for data from the server - client.on("data", function (data) { - const recommendations = JSON.parse(data.toString()); - console.log( - `Recommendations for User ${userId}:`, - recommendations.recommendations, - ); - - // Close the connection after receiving the response - client.destroy(); - }); - - // Handle connection errors - client.on("error", function (error) { - console.error("Connection error:", error.message); - }); - - // Handle connection close - client.on("close", function () { - console.log(`Connection to server closed for User ${userId}`); - }); -} - -// Function to simulate multiple users requesting recommendations -function simulateClients() { - for (let i = 1; i <= 5; i++) { - setTimeout(() => { - getRecommendations(i); // Simulate clients with IDs 1 to 5 - }, i * 1000); // Stagger requests every second - } -} - -simulateClients();