Skip to content
Snippets Groups Projects
Commit 51e61150 authored by arshiam2's avatar arshiam2
Browse files

updated join

parent d85f7428
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ module.exports.builder = (yargs: any) => yargs; ...@@ -11,7 +11,7 @@ module.exports.builder = (yargs: any) => yargs;
const PORT = 20000; const PORT = 20000;
const MULTICAST_ADDR = "233.255.255.255"; const MULTICAST_ADDR = "233.255.255.255";
const HOST = "172.22.158.15"; const HOST = "172.22.158.17";
// const HOST = "fa18-cs425-g05-02.cs.illinois.edu"; // const HOST = "fa18-cs425-g05-02.cs.illinois.edu";
const dgram = require("dgram"); const dgram = require("dgram");
...@@ -22,19 +22,41 @@ const socket = dgram.createSocket({ type: "udp4", reuseAddr: true }); ...@@ -22,19 +22,41 @@ const socket = dgram.createSocket({ type: "udp4", reuseAddr: true });
const server = i => const server = i =>
`ws://fa18-cs425-g05-${String(i).padStart(2, "0")}.cs.illinois.edu:80`; // gets the name of the server `ws://fa18-cs425-g05-${String(i).padStart(2, "0")}.cs.illinois.edu:80`; // gets the name of the server
// 1 : 172.22.156.15
// 2 : 172.22.158.15
// 3 : 172.22.154.16
// 4 : 172.22.156.16
// 5 : 172.22.158.16
// 6 : 172.22.154.17
// 8 : 172.22.158.17
// 9 : 172.22.154.18
// 10: 172.22.156.18
const machineToIps = {
"1" : "172.22.156.15",
"2" : "172.22.158.15",
"3" : "172.22.154.16",
"4" : "172.22.156.16",
"5" : "172.22.158.16",
"6" : "172.22.154.17",
"8" : "172.22.158.17",
"9" : "172.22.154.18",
"10" : "172.22.156.18"
}
socket.bind(PORT); socket.bind(PORT);
function sendMessage() { function sendMessage(host) {
const message = Buffer.from(`cli ${process.pid}`); const message = Buffer.from(`cli ${process.pid}`);
socket.send(message, 0, message.length, PORT, HOST, function() {}); console.log(host)
socket.send(message, 0, message.length, PORT, host, function() {});
} }
module.exports.handler = handleErrors(async (argv: {}) => { module.exports.handler = handleErrors(async (argv: {}) => {
console.log("Sending message to introducer") console.log("Sending message to introducer")
let number = argv.number let number = argv.number
console.log(server(number)) await sendMessage(machineToIps[number]);
await sendMessage();
process.exit(0); process.exit(0);
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment