Commit c3d1601f authored by Mat's avatar Mat

hop

parent 3e1184bd
......@@ -37,7 +37,7 @@ class WsCommand extends ContainerAwareCommand
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->write("Tentative de connexion au chat\n");
$output->write("Connexion au chat..\n");
// méthode 1
$server = IoServer::factory(
......
......@@ -12,19 +12,6 @@ use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;
class ChatController extends Controller
{
// on peut mettre ça aussi dans les annotations
// * @Security("has_role('ROLE_ADMIN')")
/**
* @Route(name="chat_message", path="/socket/chat")
*/
public function messageAction()
{
return $this->render('@Socket/Chat/message.html.twig');
}
/**
* @Route(name="login", path="/login")
......@@ -42,6 +29,7 @@ class ChatController extends Controller
));
}
/**
* @Route(name="register", path="/register")
* @return \Symfony\Component\HttpFoundation\Response
......@@ -73,4 +61,14 @@ class ChatController extends Controller
}
/**
* @Route(name="chat_message", path="/socket/chat")
*/
public function messageAction()
{
return $this->render('@Socket/Chat/message.html.twig', array(
'token' => $token
));
}
}
......@@ -29,6 +29,7 @@ class ChatHub implements MessageComponentInterface
*/
private $clients;
/**
* ChatHub constructor.
*
......@@ -50,7 +51,7 @@ class ChatHub implements MessageComponentInterface
function onOpen(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
*/
function onClose(ConnectionInterface $conn)
{
// TODO: Implement onClose() method.
echo "Un utilisateur s'est déconnecté\n";
foreach ($this->clients as $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
*/
function onError(ConnectionInterface $conn, \Exception $e)
{
// TODO: Implement onError() method.
echo "Une erreur s'est produite\n";
}
/**
* Triggered when a client sends data through the socket
*
......@@ -118,4 +120,5 @@ class ChatHub implements MessageComponentInterface
$client->send($response);
}
}
}
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