From 68e718cc54424a130776418e60802c3a24bb84ac Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Tue, 1 Nov 2011 11:14:23 -0400 Subject: [PATCH] Documentation Updated the simple user documentation in README --- README.md | 43 +++++++++++++++++++++++++++---------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index dd78ac3..c64df97 100644 --- a/README.md +++ b/README.md @@ -14,31 +14,42 @@ Ratchet (so far) includes an "application" (in development) to handle the WebSoc _clients = new \SplObjectStorage; } - public function setUp(Server $server) { - $this->_server = $server; + public function onOpen(SocketInterface $conn) { + $this->_clients->attach($conn); } - public function onOpen(Sock $conn) { + public function onRecv(SocketInterface $from, $msg) { + $stack = new SocketCollection; + foreach ($this->_clients as $client) { + if ($from != $client) { + $stack->enqueue($client); + } + } + + $command = new SendMessage($stack); + $command->setMessage($msg); + return $command; } - public function onRecv(Sock $from, $msg) { - } - - public function onClose(Sock $conn) { + public function onClose(SocketInterface $conn) { + $this->_clients->detach($conn); } } - $server = new Server(new Socket, new WebSocket(new MyApp)); + // Run the server application through the WebSocket protocol + $server = new Server(new Socket, new WebSocket(new Chat)); $server->run('0.0.0.0', 80); \ No newline at end of file