Skip to content

Latest commit

 

History

History
36 lines (29 loc) · 671 Bytes

README.md

File metadata and controls

36 lines (29 loc) · 671 Bytes

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();