hi i am writing a simple game with php ,
for this work i use http://socketo.me it have a method "onOpen()" that it is like this code
PHP :
public function onOpen(ConnectionInterface $conn) {
// Store the new connection to send messages to later
$this->clients->attach($conn);
echo "New connection! ({$conn->resourceId})\n";
}
i can access to a ConnectionInterface for each clients that it contain a resourceId or a remoteAddress (ipaddress of the client)
but in my application people first login to the web site then they connect to server but the only thing that i have from the clients on the server is a ConnectionInterface
how can i know that each $conn is for which user?
In the documentation on the socketo.me web site, there is this page http://socketo.me/docs/sessions
Each ConnectionInferface has a SessionProvider object. Their example code
// Inside your MyApp class
public function onOpen($conn) {
$conn->send('Hello ' . $conn->Session->get('name'));
}
The session object will have info regarding the logged in user