wip
This commit is contained in:
parent
1cfe2c8776
commit
a632b43b56
|
|
@ -8,7 +8,8 @@ use Ratchet\Http\HttpServerInterface;
|
||||||
use Ratchet\MessageComponentInterface;
|
use Ratchet\MessageComponentInterface;
|
||||||
use Psr\Http\Message\RequestInterface;
|
use Psr\Http\Message\RequestInterface;
|
||||||
|
|
||||||
class OriginCheck implements HttpServerInterface {
|
class OriginCheck implements HttpServerInterface
|
||||||
|
{
|
||||||
|
|
||||||
use CloseResponseTrait;
|
use CloseResponseTrait;
|
||||||
|
|
||||||
|
|
@ -17,13 +18,14 @@ class OriginCheck implements HttpServerInterface {
|
||||||
|
|
||||||
protected $allowedOrigins = [];
|
protected $allowedOrigins = [];
|
||||||
|
|
||||||
public function __construct(MessageComponentInterface $component, array $allowedOrigins = []) {
|
public function __construct(MessageComponentInterface $component, array $allowedOrigins = [])
|
||||||
|
{
|
||||||
$this->_component = $component;
|
$this->_component = $component;
|
||||||
$this->allowedOrigins = $allowedOrigins;
|
$this->allowedOrigins = $allowedOrigins;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onOpen(ConnectionInterface $connection, RequestInterface $request = null) {
|
public function onOpen(ConnectionInterface $connection, RequestInterface $request = null)
|
||||||
|
{
|
||||||
if ($request->hasHeader('Origin')) {
|
if ($request->hasHeader('Origin')) {
|
||||||
$this->verifyOrigin($connection, $request);
|
$this->verifyOrigin($connection, $request);
|
||||||
}
|
}
|
||||||
|
|
@ -31,15 +33,18 @@ class OriginCheck implements HttpServerInterface {
|
||||||
return $this->_component->onOpen($connection, $request);
|
return $this->_component->onOpen($connection, $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onMessage(ConnectionInterface $from, $msg) {
|
function onMessage(ConnectionInterface $from, $msg)
|
||||||
|
{
|
||||||
return $this->_component->onMessage($from, $msg);
|
return $this->_component->onMessage($from, $msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClose(ConnectionInterface $connection) {
|
function onClose(ConnectionInterface $connection)
|
||||||
|
{
|
||||||
return $this->_component->onClose($connection);
|
return $this->_component->onClose($connection);
|
||||||
}
|
}
|
||||||
|
|
||||||
function onError(ConnectionInterface $connection, \Exception $e) {
|
function onError(ConnectionInterface $connection, \Exception $e)
|
||||||
|
{
|
||||||
return $this->_component->onError($connection, $e);
|
return $this->_component->onError($connection, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue