Commit 8c5e5fd7 authored by Mat's avatar Mat

hop

parent eca08127
......@@ -41,20 +41,20 @@ class WsCommand extends ContainerAwareCommand
{
$output->write("Tentative de connexion au chat\n");
/*
// méthode 1
$server = IoServer::factory(
new HttpServer(
new WsServer(
new ChatHub($this->getContainer())
)
), 8088, 'ws://0.0.0.0/socket'
), 8088, '0.0.0.0'
);
*/
/*
// méthode 2
$server = new App('0.0.0.0', 8088);
$server->route('/', new ChatHub($this->getContainer()));
*/
$server->run();
......
......@@ -73,6 +73,14 @@ class ChatHub implements MessageComponentInterface
{
// TODO: Implement onClose() method.
echo "Un utilisateur s'est déconnecté\n";
foreach ($this->clients as $key => $client)
{
if ($client === $conn)
{
unset($this->clients[$key]);
}
}
}
/**
......@@ -98,7 +106,7 @@ class ChatHub implements MessageComponentInterface
*/
function onMessage(ConnectionInterface $from, $msg)
{
echo "Le message ". $msg ." a été reçu\n";
echo "Le message '". $msg ."' a été reçu\n";
foreach ($this->clients as $client)
{
$response = json_encode([
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment