Merge branch 'refs/heads/0.2-beta' into wamp-topics
Conflicts: composer.lock
This commit is contained in:
commit
9d0e6735db
3
Makefile
3
Makefile
@ -1,3 +1,6 @@
|
||||
# This file is intended to ease the author's development and testing process
|
||||
# Users do not need to use `make`; Ratchet does not need to be compiled
|
||||
|
||||
test:
|
||||
phpunit
|
||||
|
||||
|
@ -41,6 +41,8 @@ use Ratchet\ConnectionInterface;
|
||||
use Ratchet\Server\IoServer;
|
||||
use Ratchet\WebSocket\WsServer;
|
||||
|
||||
require __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
/**
|
||||
* chat.php
|
||||
* Send any incoming messages to all connected clients (except sender)
|
||||
|
14
composer.lock
generated
14
composer.lock
generated
@ -3,9 +3,7 @@
|
||||
"packages": [
|
||||
{
|
||||
"package": "evenement/evenement",
|
||||
"version": "1.0.x-dev",
|
||||
"source-reference": "v1.0.0",
|
||||
"commit-date": "1338390068"
|
||||
"version": "v1.0.0"
|
||||
},
|
||||
{
|
||||
"package": "guzzle/guzzle",
|
||||
@ -29,15 +27,7 @@
|
||||
},
|
||||
{
|
||||
"package": "symfony/http-foundation",
|
||||
"version": "dev-master",
|
||||
"alias-pretty-version": "2.1.x-dev",
|
||||
"alias-version": "2.1.9999999.9999999-dev"
|
||||
},
|
||||
{
|
||||
"package": "symfony/http-foundation",
|
||||
"version": "dev-master",
|
||||
"source-reference": "v2.1.0-BETA3",
|
||||
"commit-date": "1342347231"
|
||||
"version": "v2.1.0-BETA3"
|
||||
}
|
||||
],
|
||||
"packages-dev": null,
|
||||
|
@ -7,19 +7,13 @@ use React\Socket\ConnectionInterface as ReactConn;
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
class IoConnection implements ConnectionInterface {
|
||||
/**
|
||||
* @var Ratchet\Server\IOServer
|
||||
*/
|
||||
protected $server;
|
||||
|
||||
/**
|
||||
* @var React\Socket\ConnectionInterface
|
||||
*/
|
||||
protected $conn;
|
||||
|
||||
public function __construct(ReactConn $conn, IoServer $server) {
|
||||
public function __construct(ReactConn $conn) {
|
||||
$this->conn = $conn;
|
||||
$this->server = $server;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,9 +31,9 @@ class IoServer {
|
||||
/**
|
||||
* @param Ratchet\MessageComponentInterface The Ratchet application stack to host
|
||||
* @param React\Socket\ServerInterface The React socket server to run the Ratchet application off of
|
||||
* @param React\EventLoop\LoopInterface The React looper to run the Ratchet application off of
|
||||
* @param React\EventLoop\LoopInterface|null The React looper to run the Ratchet application off of
|
||||
*/
|
||||
public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop) {
|
||||
public function __construct(MessageComponentInterface $app, ServerInterface $socket, LoopInterface $loop = null) {
|
||||
gc_enable();
|
||||
set_time_limit(0);
|
||||
ob_implicit_flush();
|
||||
@ -64,8 +64,13 @@ class IoServer {
|
||||
|
||||
/**
|
||||
* Run the application by entering the event loop
|
||||
* @throws RuntimeException If a loop was not previously specified
|
||||
*/
|
||||
public function run() {
|
||||
if (null === $this->loop) {
|
||||
throw new \RuntimeException("A React Loop was not provided during instantiation");
|
||||
}
|
||||
|
||||
$this->loop->run();
|
||||
}
|
||||
|
||||
@ -73,7 +78,7 @@ class IoServer {
|
||||
* Triggered when a new connection is received from React
|
||||
*/
|
||||
public function handleConnect($conn) {
|
||||
$conn->decor = new IoConnection($conn, $this);
|
||||
$conn->decor = new IoConnection($conn);
|
||||
|
||||
$conn->decor->resourceId = (int)$conn->stream;
|
||||
$conn->decor->remoteAddress = $conn->getRemoteAddress();
|
||||
|
@ -20,7 +20,7 @@ class IoServerTest extends \PHPUnit_Framework_TestCase {
|
||||
public function setUp() {
|
||||
$this->app = new Component;
|
||||
|
||||
$loop = new StreamSelectLoop(0);
|
||||
$loop = new StreamSelectLoop;
|
||||
$this->reactor = new Server($loop);
|
||||
$this->reactor->listen(0);
|
||||
|
||||
@ -86,4 +86,12 @@ class IoServerTest extends \PHPUnit_Framework_TestCase {
|
||||
public function testFactory() {
|
||||
$this->assertInstanceOf('\\Ratchet\\Server\\IoServer', IoServer::factory($this->app, 0));
|
||||
}
|
||||
|
||||
public function testNoLoopProvidedError() {
|
||||
$loop = new StreamSelectLoop;
|
||||
$io = new IoServer(new Component, new Server($loop));
|
||||
|
||||
$this->setExpectedException('RuntimeException');
|
||||
$io->run();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user