Search code examples
erlangwebsocketyaws

Yaws websocket send message to all connected users


I am using yaws (Erlang framework) for socket communication. I can send message back to the user from server using websocket_send however i need to specify the PID of the user, that means that i can send message back to that user. However, i would like to send message to all connected users. Is there any way to do it?


Solution

  • Got it worked !!! Using GProc :)

    Gproc is a process dictionary for Erlang, which provides a number of useful features beyond what the built-in dictionary has:

    Use any term as a process alias
    
    Register a process under several aliases
    
    Non-unique properties can be registered simultaneously by many processes
    
    QLC and match specification interface for efficient queries on the dictionary
    
    Await registration, let's you wait until a process registers itself
    
    Atomically give away registered names and properties to another process
    
    Counters, and aggregated counters, which automatically maintain the total of all counters with a given name
    
    Global registry, with all the above functions applied to a network of nodes