From 6a5c70877557e735030de53ba039435bf46ff924 Mon Sep 17 00:00:00 2001 From: Chris Boden Date: Tue, 1 Nov 2011 14:34:29 -0400 Subject: [PATCH] README Added PHP syntax to README --- README.md | 76 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 39 insertions(+), 37 deletions(-) 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