SHARE
TWEET

Untitled

a guest Jun 25th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var socket = io();
  2.  
  3. socket.on("connect", () => {  
  4.   button.addEventListener("click", function() {
  5.      socket.emit("send", {room, message, client1_id, client2_id});
  6.   })
  7. })
  8.      
  9. var socket = io();
  10.  
  11. socket.on("connect", () => {
  12.   socket.emit("send_id", (socket.io.engine.id))
  13.   socket.on(client2_id, (data) => {
  14.     console.log(data);
  15.   })
  16. })
  17.      
  18. var tech = io.of("/");
  19.  
  20. tech.on("connection", (socket) => {
  21.   var receiver_id;
  22.   socket.on("send_id", (data) => {
  23.     receiver_id = data;
  24.   })
  25.   socket.on("send", data => {
  26.     io.to(receiver_id).emit(data.client2_id, "hello");
  27.   })
  28. })
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top