Created
May 10, 2014 13:51
-
-
Save cboden/09e9a716ce64ff2a2b74 to your computer and use it in GitHub Desktop.
Account for expected errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyNamespace; | |
use Ratchet\MessageComponentInterface; | |
use Ratchet\ConnectionInterface; | |
class AccountedExceptions MessageComponentInterface { | |
protected $_app; | |
public function __construct($app) { | |
$this->_app = $app; | |
} | |
public function onOpen(ConnectionInterface $conn) { | |
$this->_app->onOpen($conn); | |
} | |
public function onMessage(ConnectionInterface $from, $msg) { | |
$this->_app->onMessage($from, $msg); | |
} | |
public function onClose(ConnectionInterface $conn) { | |
$this->_app->onClose($conn); | |
} | |
public function onError(ConnectionInterface $conn, \Exception $e) { | |
if ('Tried to write to closed stream.' !== $e->getMessage()) { | |
$this->_app->onError($conn, $e); | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace MyNamespace; | |
$server = new Ratchet\App; | |
$server->route('/', new AccountedExceptions(new Ratchet\Server\EchoServer())); | |
$server->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment