diff --git a/src/Ratchet/WebSocket/BinaryMessageInterface.php b/src/Ratchet/WebSocket/BinaryMessageInterface.php deleted file mode 100644 index e5dc022..0000000 --- a/src/Ratchet/WebSocket/BinaryMessageInterface.php +++ /dev/null @@ -1,8 +0,0 @@ -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; @@ -106,7 +124,8 @@ class WsServer implements HttpServerInterface { $streamer = new MessageBuffer( $this->closeFrameChecker, function(MessageInterface $msg) use ($wsConn) { - $this->delegate->onMessage($wsConn, $msg->getPayload(), $msg->isBinary()); + $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 4b0fb84..5dcbf66 100644 --- a/tests/autobahn/bin/fuzzingserver.php +++ b/tests/autobahn/bin/fuzzingserver.php @@ -1,10 +1,20 @@ send($msg, $isBinary); +class BinaryEcho implements \Ratchet\WebSocket\MessageComponentInterface { + public function onMessage(ConnectionInterface $from, \Ratchet\RFC6455\Messaging\MessageInterface $msg) { + $from->send($msg); + } + + public function onOpen(ConnectionInterface $conn) { + } + + public function onClose(ConnectionInterface $conn) { + } + + public function onError(ConnectionInterface $conn, \Exception $e) { } }