Commit 12ce64b3 authored by Mat's avatar Mat

ce qu'il faut pour que le serveur websocket puisse démarrer

parent 63b6c2d3
......@@ -9,6 +9,10 @@
namespace SocketBundle\Command;
use Ratchet\Http\HttpServer;
use Ratchet\Server\IoServer;
use Ratchet\WebSocket\WsServer;
use SocketBundle\Services\ChatHub;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
......@@ -34,7 +38,16 @@ class WsCommand extends ContainerAwareCommand
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$output->write("Hello");
$output->write("Tentative de connexion au chat");
$server = IoServer::factory(
new HttpServer(
new WsServer(
new ChatHub($this->getContainer())
)
), 8080
);
$server->run();
//parent::execute($input, $output); // pas nécessaire ici
}
......
......@@ -10,6 +10,7 @@ namespace SocketBundle\Services;
use Ratchet\ConnectionInterface;
use Ratchet\MessageComponentInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ChatHub implements MessageComponentInterface
{
......@@ -18,6 +19,15 @@ class ChatHub implements MessageComponentInterface
* et hop, il ajoute tout ce qui doit être implémenté
*/
private $container;
private $clients;
public function __construct(ContainerInterface $_container)
{
$this->container = $_container;
$this->clients = array();
}
/**
* When a new connection is opened it will be passed to this method
......
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