Skip to content
Snippets Groups Projects
Commit 70e6b1ac authored by Kens's avatar Kens
Browse files

Final project stuff for maroon

parent 3784ea91
No related branches found
No related tags found
No related merge requests found
//listen to muticast
//Multicast Client receiving sent messages
var PORT = 3000;
var MCAST_ADDR = "239.1.2.3"; //same mcast address as Server
var HOST = '172.20.159.255'; //this is your own IP
var dgram = require('dgram');
var client = dgram.createSocket('udp4');
//set up WebSocket repeater
const WebSocket = require('ws');
const websocket = new WebSocket('ws://track.movesinstitute.org:80');
websocket.onopen = function(evt){console.log("Opened websocket");};//console.log("websocket onopen");};
websocket.onclose = function(evt){console.log("websocket close", evt);};
websocket.onerror = function(evt){console.log("websocket error", evt.data);};
client.on('listening', function () {
var address = client.address();
console.log('UDP Client listening on ' + address.address + ":" + address.port);
client.setBroadcast(true)
client.setMulticastTTL(128);
client.addMembership(MCAST_ADDR);
});
client.on('message', function (message, remote) {
console.log('MCast Msg: From: ' + remote.address + ':' + remote.port +' - ' + message);
websocket.send(message);
});
client.bind(PORT, HOST);
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