Updated the README file to reflect application structure changes
This commit is contained in:
Chris Boden 2011-10-28 14:20:25 -04:00
parent 51d0516aa3
commit 07f5d49996

View File

@ -14,27 +14,31 @@ Ratchet (so far) includes an "application" (in development) to handle the WebSoc
<?php <?php
namespace Me; namespace Me;
use Ratchet\Socket;
use Ratchet\SocketInterface as Sock;
use Ratchet\Server;
use Ratchet\Protocol\WebSocket;
class MyApp implements \Ratchet\ReceiverInterface { class MyApp implements \Ratchet\ReceiverInterface {
protected $_server;
public function getName() { public function getName() {
return 'my_app'; return 'my_app';
} }
public function handleConnect() { public function setUp(Server $server) {
$this->_server = $server;
} }
public function handleMessage() { public function onOpen(Sock $conn) {
} }
public function handleClose() { public function onRecv(Sock $from, $msg) {
}
public function onClose(Sock $conn) {
} }
} }
$protocol = new \Ratchet\Protocol\WebSocket(); $server = new Server(new Socket, new WebSocket(new MyApp));
$application = new MyApp(); $server->run('0.0.0.0', 80);
$server = new \Ratchet\Server(\Ratchet\Socket::createFromConfig($protocol));
$server->attatchReceiver($protocol);
$server->attatchReceiver($application);
$server->run();