udp-radio

UDP based broadcasting and receiving module, It expects an JS Object and returns the same on the otherside :P


Keywords
UDP, Broadcast, Receive, Network, udp-broadcast, udp-socket
License
MIT
Install
npm install udp-radio@1.2.0

Documentation

udp-radio

UDP based broadcasting and receiving module, It expects an JS Object and returns the same on the otherside

Instalation

$ npm install upd-radio

Usages

Requiring the package

const Radio = require('udp-radio');

Async receiving any broadcast

const BROADCAST_ADDR = "127.0.0.1";
const BROADCAST_PORT = 9999
let channel_0 = new Radio(BROADCAST_ADDR, BROADCAST_PORT, (message, info)=>{
    // on receiving of a radio broadcast
    console.log(message);
})

Async send any broadcast

const message = {
  _type: "LOGOUT",
  _content: os.hostname();
}
channel_0.broadcast(message);
channel_0.close();