JS
(quick guide & example)
NPM INSTALL PEER THEN RUN THIS SCRIPT IN TERMINAL
const { PeerServer } = require("peer"); const peerServer = PeerServer({ port: 9000, path: "/myapp" });
CONNECT TO PEER SERVER const peer = new Peer("PEER-A", { host: "localhost", port: 9000, path: "/myapp"});
ON RECEIVING MESSAGE peer.on("connection", conn => conn.on("data", data => console.log(data)));
CONNECT TO PEER SERVER const peer = new Peer("PEER-B", { host: "localhost", port: 9000, path: "/myapp"});
SEND MESSAGE TO A peer.on("open", id => { var conn = peer.connect("PEER-A"); conn.on("open", () => conn.send("Hi!")); });