Free Friday

Today I fixed my site. I have a site to talk my friends using WebRTC. I had a bug that when more than two people the public key will not share and they can not hear each other. So I made it push out the key to all people in the call

  // Receive and store client's public key (JWK) and relay to room
  socket.on("public-key", ({ roomId, publicKeyJwk }) => {
    if (!roomId || !publicKeyJwk) return;
    rooms[roomId] = rooms[roomId] || {};
    rooms[roomId][socket.id] = rooms[roomId][socket.id] || {};
    rooms[roomId][socket.id].publicKeyJwk = publicKeyJwk;

    // relay this public key to others in room (so they can derive pairwise keys)
    socket.to(roomId).emit("user-public-key", {
      socketId: socket.id,
      publicKeyJwk,
    });
  });

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top