@@ -29,6 +29,7 @@ class ChatHub implements MessageComponentInterface
*/
private$clients;
/**
* ChatHub constructor.
*
...
...
@@ -50,7 +51,7 @@ class ChatHub implements MessageComponentInterface
functiononOpen(ConnectionInterface$conn)
{
echo"Un utilisateur s'est connecté\n";
$this->clients[]=$conn;
$response=json_encode([
...
...
@@ -63,6 +64,7 @@ class ChatHub implements MessageComponentInterface
$conn->send($response);
}
/**
* This is called before or after a socket is closed (depends on how it's closed). SendMessage to $conn will not result in an error if it has already been closed.
*
...
...
@@ -71,7 +73,6 @@ class ChatHub implements MessageComponentInterface
*/
functiononClose(ConnectionInterface$conn)
{
// TODO: Implement onClose() method.
echo"Un utilisateur s'est déconnecté\n";
foreach($this->clientsas$key=>$client)
...
...
@@ -83,6 +84,7 @@ class ChatHub implements MessageComponentInterface
}
}
/**
* If there is an error with one of the sockets, or somewhere in the application where an Exception is thrown,
* the Exception is sent back down the stack, handled by the Server and bubbled back up the application through this method
...
...
@@ -93,10 +95,10 @@ class ChatHub implements MessageComponentInterface