rfc6455/Version/RFC6455/Connection.php
Chris Boden 8770c361bc [WebSocket] Hixie refactoring
Created parent interface for messages and frames
Created Hixie Connection
Applied updated interfaces to Hixie versions
Removed __toString on msgs/frames since there could be 2-3 types returned
2012-06-14 15:07:52 -04:00

27 lines
635 B
PHP

<?php
namespace Ratchet\WebSocket\Version\RFC6455;
use Ratchet\ConnectionInterface;
use Ratchet\AbstractConnectionDecorator;
use Ratchet\WebSocket\Version\DataInterface;
/**
* {@inheritdoc}
*/
class Connection extends AbstractConnectionDecorator {
public function send($msg) {
if (!($msg instanceof DataInterface)) {
$msg = new Frame($msg);
}
$this->getConnection()->send($msg->getContents());
}
/**
* {@inheritdoc}
*/
public function close($code = 1000) {
$this->send(new Frame($code, true, Frame::OP_CLOSE));
$this->getConnection()->close();
}
}