0

I'd like to know how could I use webRTC to send a message from Node.JS to my Browser without having to install any third-party lib on the Browser end.

I've researched a few options but they all were outdated or over complicated. I just need to print something on the console, no UI, no nothing.

Maybe someone could help me out with a snippet or example?

Thank you

1 Answers1

1

the easiest way is to use socket.io to send node server to browsers without having to install any plugin or lib on browser side(you need to add socket.io.js to your code). onces you setup socket.io you can basicly send data from node server to browser by

client.emit("message",message);

and you can get this from client side like

socket.on("message",function(message){
     //do something with message
}};

you can find more information from https://socket.io/docs/ about socket.io

if you would like to send data from browser to browser you need to set up a signaling server to connect the peers. from https://github.com/webrtc/samples link you can find lots of examples for WebRTC implementations for different scen

mentes
  • 120
  • 3
  • 14