Let's say i want to identify each user that initiate a connection to a php websocket server (Ratchet).
Each user have an unique token in my database (not enough secure i know, but let's keep this example simple).
I have to send this token when opening the connection to the WS server and check in my database if it match any user and if yes allowing to continue and storing the connection id of the WS to be able to link the user to the ws connection.
Then connected user id 1 want's to send a message to connected user id 2
Do i have to search in the database the connection id of user 2 to be able to send the message ? or does there is an alternative, like a global array which stay in the memory or something and where the WS server can access it all time ? this would be less heavy than requesting the database if i just could store a link between "user Id" and "ws connection Id" directly in the memory or something