Commit 966818dd authored by Mat's avatar Mat

hop

parent 89796d7e
...@@ -40,7 +40,7 @@ class WsCommand extends ContainerAwareCommand ...@@ -40,7 +40,7 @@ class WsCommand extends ContainerAwareCommand
$port = 8088; $port = 8088;
$address = '0.0.0.0'; $address = '0.0.0.0';
$output->write("\nConnexion du serveur Web Socket..\nlistening on $address:$port\n\n"); $output->write("+=--\nConnexion du serveur Web Socket..\nlistening on $address:$port\n+=--\n");
// méthode 1 // méthode 1
$server = IoServer::factory( $server = IoServer::factory(
......
...@@ -74,10 +74,8 @@ class ChatHub implements MessageComponentInterface ...@@ -74,10 +74,8 @@ class ChatHub implements MessageComponentInterface
{ {
echo "Un utilisateur s'est déconnecté\n"; echo "Un utilisateur s'est déconnecté\n";
foreach ($this->clients as $key => $client) foreach ($this->clients as $key => $client) {
{ if ($client === $conn) {
if ($client === $conn)
{
unset($this->clients[$key]); unset($this->clients[$key]);
} }
} }
...@@ -114,6 +112,7 @@ class ChatHub implements MessageComponentInterface ...@@ -114,6 +112,7 @@ class ChatHub implements MessageComponentInterface
$dataPath = $data->path; // la route qui nous mène qqpart $dataPath = $data->path; // la route qui nous mène qqpart
$dataToken = $data->token; // token d'identification $dataToken = $data->token; // token d'identification
// le token brut, façon JWT
$token = new JWTUserToken(); $token = new JWTUserToken();
$token->setRawToken($dataToken); $token->setRawToken($dataToken);
...@@ -144,16 +143,16 @@ class ChatHub implements MessageComponentInterface ...@@ -144,16 +143,16 @@ class ChatHub implements MessageComponentInterface
*/ */
private function refreshUsers() private function refreshUsers()
{ {
// twig génère le fragment à retourner // twig va génèrer le fragment à retourner
$twig = $this->container->get('templating'); $twig = $this->container->get('templating');
$partialView = $twig->render('@Socket/Chat/listUsers.html.twig', array( $fragment = $twig->render('@Socket/Chat/listUsers.html.twig', array(
'usernames' => array_keys($this->clients) 'usernames' => array_keys($this->clients)
)); ));
// formate la response // formate la response
$response = json_encode(array( $response = json_encode(array(
'action' => 'refresh_users', 'action' => 'refresh_users',
'view' => $partialView 'view' => $fragment
)); ));
// renvoie la réponse à tous les clients // renvoie la réponse à tous les clients
......
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