Pass message value, isBinary indicator
Passing message contents instead of string to keep BC Passing isBinary indicator regardless of interface
This commit is contained in:
parent
365e8702ff
commit
7e42bfe2ac
@ -106,7 +106,7 @@ class WsServer implements HttpServerInterface {
|
||||
$streamer = new MessageBuffer(
|
||||
$this->closeFrameChecker,
|
||||
function(MessageInterface $msg) use ($wsConn) {
|
||||
$this->delegate->onMessage($wsConn, $msg);
|
||||
$this->delegate->onMessage($wsConn, $msg->getPayload(), $msg->isBinary());
|
||||
},
|
||||
function(FrameInterface $frame) use ($wsConn) {
|
||||
$this->onControlFrame($frame, $wsConn);
|
||||
|
@ -2,12 +2,18 @@
|
||||
|
||||
require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php';
|
||||
|
||||
class BinaryEcho extends \Ratchet\Server\EchoServer implements \Ratchet\WebSocket\BinaryMessageInterface {
|
||||
public function onMessage(\Ratchet\ConnectionInterface $from, $msg, $isBinary = false) {
|
||||
$from->send($msg, $isBinary);
|
||||
}
|
||||
}
|
||||
|
||||
$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');
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user