Search Unity

Custom Nodejs Server Unity Client

Discussion in 'Multiplayer' started by blqck, Jul 23, 2017.

  1. blqck

    blqck

    Joined:
    Dec 2, 2012
    Posts:
    23
    Hi community,

    i'm implementing a custom chat server with nodejs and socket io.
    basiclly ,players gonna chat only in private , so the user need to select another player to chat with him.

    actually this is what i implement, but i didnt find a way to tell the second user to join the private room.
    this is my server code

    Code (JavaScript):
    1. socket.on('connection', function (socket)
    2. {
    3.     console.log("client Unity connected ");
    4.  
    5.  
    6.     socket.on('registerChat', function(data)
    7.     {
    8.         roomId =  data.rev+data.me;
    9.  
    10.        
    11.             socket.join(roomId);
    12.                 console.log("client Unity Joint room ", data.rev+data.me);
    13.                     socket.broadcast.to(roomId).emit('successReg',roomId);
    14.     });
    15. });
    this will add only the player who emit the registerChat event.
    my question is how to add the receiver to this room dynamically