Binary messaging support
Least obtrusive interface
This commit is contained in:
parent
1b4c534e6a
commit
2283bdf288
8
src/Ratchet/WebSocket/BinaryMessageInterface.php
Normal file
8
src/Ratchet/WebSocket/BinaryMessageInterface.php
Normal file
@ -0,0 +1,8 @@
|
||||
<?php
|
||||
namespace Ratchet\WebSocket;
|
||||
use Ratchet\MessageComponentInterface;
|
||||
use Ratchet\ConnectionInterface;
|
||||
|
||||
interface BinaryMessageInterface extends MessageComponentInterface {
|
||||
public function onMessage(ConnectionInterface $conn, $msg, $isBinary = false);
|
||||
}
|
@ -12,10 +12,10 @@ class WsConnection extends AbstractConnectionDecorator {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function send($msg) {
|
||||
public function send($msg, $isBinary = false) {
|
||||
if (!$this->WebSocket->closing) {
|
||||
if (!($msg instanceof DataInterface)) {
|
||||
$msg = new Frame($msg);
|
||||
$msg = new Frame($msg, true, ((boolean)$isBinary ? Frame::OP_TEXT : Frame::OP_BINARY));
|
||||
}
|
||||
|
||||
$this->getConnection()->send($msg->getContents());
|
||||
|
@ -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": {}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user