Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  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. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement