diff --git a/src/Ratchet/WebSocket/MessageCallableInterface.php b/src/Ratchet/WebSocket/MessageCallableInterface.php new file mode 100644 index 0000000..b5c094e --- /dev/null +++ b/src/Ratchet/WebSocket/MessageCallableInterface.php @@ -0,0 +1,8 @@ +msgCb = function(ConnectionInterface $conn, MessageInterface $msg) { + $this->delegate->onMessage($conn, $msg); + }; + } elseif ($component instanceof DataComponentInterface) { + $this->msgCb = function(ConnectionInterface $conn, MessageInterface $msg) { + $this->delegate->onMessage($conn, $msg->getPayload()); + }; + } else { + throw new \UnexpectedValueException('Expected instance of \Ratchet\WebSocket\MessageComponentInterface or \Ratchet\MessageComponentInterface'); + } + $this->delegate = $component; $this->connections = new \SplObjectStorage; @@ -105,7 +123,8 @@ class WsServer implements HttpServerInterface { $streamer = new MessageBuffer( $this->closeFrameChecker, function(MessageInterface $msg) use ($wsConn) { - $this->delegate->onMessage($wsConn, $msg); + $cb = $this->msgCb; + $cb($wsConn, $msg); }, function(FrameInterface $frame) use ($wsConn) { $this->onControlFrame($frame, $wsConn); diff --git a/tests/autobahn/bin/fuzzingserver.php b/tests/autobahn/bin/fuzzingserver.php index 093a5cf..5dcbf66 100644 --- a/tests/autobahn/bin/fuzzingserver.php +++ b/tests/autobahn/bin/fuzzingserver.php @@ -1,13 +1,29 @@ send($msg); + } + + public function onOpen(ConnectionInterface $conn) { + } + + public function onClose(ConnectionInterface $conn) { + } + + public function onError(ConnectionInterface $conn, \Exception $e) { + } +} + $port = $argc > 1 ? $argv[1] : 8000; $impl = sprintf('React\EventLoop\%sLoop', $argc > 2 ? $argv[2] : 'StreamSelect'); $loop = new $impl; $sock = new React\Socket\Server($loop); - $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new Ratchet\Server\EchoServer)); + $app = new Ratchet\Http\HttpServer(new Ratchet\WebSocket\WsServer(new BinaryEcho)); $sock->listen($port, '0.0.0.0'); diff --git a/tests/autobahn/fuzzingclient-quick.json b/tests/autobahn/fuzzingclient-quick.json index 3023fb8..c92e805 100644 --- a/tests/autobahn/fuzzingclient-quick.json +++ b/tests/autobahn/fuzzingclient-quick.json @@ -7,6 +7,6 @@ ] , "cases": ["*"] - , "exclude-cases": ["1.2.*", "2.3", "2.4", "2.6", "9.2.*", "9.4.*", "9.6.*", "9.8.*"] + , "exclude-cases": [] , "exclude-agent-cases": {} }