mxmbsocket/tests/Ratchet/Tests/Mock/Component.php
Chris Boden f729be2ef3 [WebSocket] [WAMP] Sub-Protocols
Updated how Ratchet handles WebSocket sub-protocols
Broke out WsServerInterface to not extend MessageInterface;
Components will instead use Interface segregation principle
WAMP is now able to work without the developer having to
manually enable the WAMP sub-protocol
2012-05-12 22:42:56 -04:00

36 lines
1.0 KiB
PHP

<?php
namespace Ratchet\Tests\Mock;
use Ratchet\MessageComponentInterface;
use Ratchet\WebSocket\WsServerInterface;
use Ratchet\Tests\Mock\Socket as MockSocket;
use Ratchet\ConnectionInterface;
class Component implements MessageComponentInterface, WsServerInterface {
public $last = array();
public $protocols = array();
public function __construct(ComponentInterface $app = null) {
$this->last[__FUNCTION__] = func_get_args();
}
public function onOpen(ConnectionInterface $conn) {
$this->last[__FUNCTION__] = func_get_args();
}
public function onMessage(ConnectionInterface $from, $msg) {
$this->last[__FUNCTION__] = func_get_args();
}
public function onClose(ConnectionInterface $conn) {
$this->last[__FUNCTION__] = func_get_args();
}
public function onError(ConnectionInterface $conn, \Exception $e) {
$this->last[__FUNCTION__] = func_get_args();
}
public function getSubProtocols() {
return $this->protocols;
}
}