Merge branch 'refs/heads/master' into 0.4
This commit is contained in:
commit
f7bd1fca89
@ -1,10 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "cboden/Ratchet"
|
"name": "cboden/ratchet"
|
||||||
, "type": "library"
|
, "type": "library"
|
||||||
, "description": "PHP WebSocket library"
|
, "description": "PHP WebSocket library"
|
||||||
, "keywords": ["WebSockets", "Server", "Ratchet", "Sockets"]
|
, "keywords": ["WebSockets", "Server", "Ratchet", "Sockets"]
|
||||||
, "homepage": "http://socketo.me"
|
, "homepage": "http://socketo.me"
|
||||||
, "repository": "https://github.com/cboden/Ratchet"
|
|
||||||
, "license": "MIT"
|
, "license": "MIT"
|
||||||
, "authors": [
|
, "authors": [
|
||||||
{
|
{
|
||||||
@ -25,8 +24,8 @@
|
|||||||
}
|
}
|
||||||
, "require": {
|
, "require": {
|
||||||
"php": ">=5.3.9"
|
"php": ">=5.3.9"
|
||||||
, "react/socket": ">=0.3.0,<0.5-dev"
|
, "react/socket": "0.3.*|0.4.*"
|
||||||
, "guzzle/http": ">=3.6.0,<3.9.0-dev"
|
, "guzzle/http": "~3.6"
|
||||||
, "symfony/http-foundation": "~2.2"
|
, "symfony/http-foundation": "~2.2"
|
||||||
, "symfony/routing": "~2.2"
|
, "symfony/routing": "~2.2"
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ namespace Ratchet\Http;
|
|||||||
use Ratchet\ConnectionInterface;
|
use Ratchet\ConnectionInterface;
|
||||||
use Guzzle\Http\Message\RequestInterface;
|
use Guzzle\Http\Message\RequestInterface;
|
||||||
use Guzzle\Http\Message\Response;
|
use Guzzle\Http\Message\Response;
|
||||||
|
use Guzzle\Http\Url;
|
||||||
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
||||||
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
|
||||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||||
@ -46,6 +47,16 @@ class Router implements HttpServerInterface {
|
|||||||
throw new \UnexpectedValueException('All routes must implement Ratchet\Http\HttpServerInterface');
|
throw new \UnexpectedValueException('All routes must implement Ratchet\Http\HttpServerInterface');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$parameters = array();
|
||||||
|
foreach($route as $key => $value) {
|
||||||
|
if ((is_string($key)) && ('_' !== substr($key, 0, 1))) {
|
||||||
|
$parameters[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$url = Url::factory($request->getPath());
|
||||||
|
$url->setQuery($parameters);
|
||||||
|
$request->setUrl($url);
|
||||||
|
|
||||||
$conn->controller = $route['_controller'];
|
$conn->controller = $route['_controller'];
|
||||||
$conn->controller->onOpen($conn, $request);
|
$conn->controller->onOpen($conn, $request);
|
||||||
}
|
}
|
||||||
|
@ -59,6 +59,7 @@ class SessionProvider implements MessageComponentInterface, WsServerInterface {
|
|||||||
// Temporarily fixing HHVM issue w/ reading ini values
|
// Temporarily fixing HHVM issue w/ reading ini values
|
||||||
$handler_name = ini_get('session.serialize_handler');
|
$handler_name = ini_get('session.serialize_handler');
|
||||||
if ('' === $handler_name) {
|
if ('' === $handler_name) {
|
||||||
|
trigger_error('ini value session.seralize_handler was empty, assuming "php" - tmp hack/fix, bad things might happen', E_USER_WARNING);
|
||||||
$handler_name = 'php';
|
$handler_name = 'php';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,8 +77,11 @@ class TopicManager implements WsServerInterface, WampServerInterface {
|
|||||||
public function onClose(ConnectionInterface $conn) {
|
public function onClose(ConnectionInterface $conn) {
|
||||||
$this->app->onClose($conn);
|
$this->app->onClose($conn);
|
||||||
|
|
||||||
foreach ($this->topicLookup as $topic) {
|
foreach ($this->topicLookup as $topic => $storage) {
|
||||||
$topic->remove($conn);
|
$storage->remove($conn);
|
||||||
|
if (0 === $storage->count()) {
|
||||||
|
unset($this->topicLookup[$topic]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace Ratchet\Http;
|
namespace Ratchet\Http;
|
||||||
use Ratchet\Http\Router;
|
use Ratchet\Http\Router;
|
||||||
|
use Ratchet\WebSocket\WsServerInterface;
|
||||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||||
|
use Symfony\Component\Routing\Matcher\UrlMatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers Ratchet\Http\Router
|
* @covers Ratchet\Http\Router
|
||||||
@ -85,4 +87,27 @@ class RouterTest extends \PHPUnit_Framework_TestCase {
|
|||||||
|
|
||||||
$this->_router->onError($this->_conn, $e);
|
$this->_router->onError($this->_conn, $e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRouterGeneratesRouteParameters()
|
||||||
|
{
|
||||||
|
/** @var $controller WsServerInterface */
|
||||||
|
$controller = $this->getMockBuilder('\Ratchet\WebSocket\WsServer')->disableOriginalConstructor()->getMock();
|
||||||
|
/** @var $matcher UrlMatcherInterface */
|
||||||
|
$this->_matcher->expects($this->any())->method('match')->will(
|
||||||
|
$this->returnValue(array('_controller' => $controller, 'foo' => 'bar', 'baz' => 'qux'))
|
||||||
|
);
|
||||||
|
$conn = $this->getMock('Ratchet\Mock\Connection');
|
||||||
|
|
||||||
|
$request = $this->getMock('Guzzle\Http\Message\Request', array('getPath'), array('GET', 'ws://random.url'), '', false);
|
||||||
|
$request->expects($this->any())->method('getPath')->will($this->returnValue('ws://doesnt.matter/'));
|
||||||
|
|
||||||
|
$request->setHeaderFactory($this->getMock('Guzzle\Http\Message\Header\HeaderFactoryInterface'));
|
||||||
|
$request->setUrl('ws://doesnt.matter/');
|
||||||
|
|
||||||
|
$router = new Router($this->_matcher);
|
||||||
|
|
||||||
|
$router->onOpen($conn, $request);
|
||||||
|
|
||||||
|
$this->assertEquals(array('foo' => 'bar', 'baz' => 'qux'), $request->getQuery()->getAll());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,12 +166,19 @@ class TopicManagerTest extends \PHPUnit_Framework_TestCase {
|
|||||||
$method = $class->getMethod('getTopic');
|
$method = $class->getMethod('getTopic');
|
||||||
$method->setAccessible(true);
|
$method->setAccessible(true);
|
||||||
|
|
||||||
|
$attribute = $class->getProperty('topicLookup');
|
||||||
|
$attribute->setAccessible(true);
|
||||||
|
|
||||||
$topic = $method->invokeArgs($this->mngr, array($name));
|
$topic = $method->invokeArgs($this->mngr, array($name));
|
||||||
|
|
||||||
|
$this->assertCount(1, $attribute->getValue($this->mngr));
|
||||||
|
|
||||||
$this->mngr->onSubscribe($this->conn, $name);
|
$this->mngr->onSubscribe($this->conn, $name);
|
||||||
$this->mngr->onClose($this->conn);
|
$this->mngr->onClose($this->conn);
|
||||||
|
|
||||||
$this->assertFalse($topic->has($this->conn));
|
$this->assertFalse($topic->has($this->conn));
|
||||||
|
|
||||||
|
$this->assertCount(0, $attribute->getValue($this->mngr));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testOnErrorBubbles() {
|
public function testOnErrorBubbles() {
|
||||||
|
Loading…
Reference in New Issue
Block a user