diff --git a/README.md b/README.md index 16033b7..d50d52f 100644 --- a/README.md +++ b/README.md @@ -15,44 +15,46 @@ Re-use your application without changing any of its code just by wrapping it in ###A Quick server example - _clients = new \SplObjectStorage; - } - - public function onOpen(SocketInterface $conn) { - $this->_clients->attach($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 onClose(SocketInterface $conn) { - $this->_clients->detach($conn); - } + public function __construct() { + $this->_clients = new \SplObjectStorage; } - // 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 + public function onOpen(SocketInterface $conn) { + $this->_clients->attach($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 onClose(SocketInterface $conn) { + $this->_clients->detach($conn); + } + } + + // 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