Skip to content

Commit 66fbc04

Browse files
committed
Fix compatibility with react/socket v1.9+ in App for FlashPolicy
1 parent 6fb60de commit 66fbc04

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/Ratchet/App.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ public function __construct($httpHost = 'localhost', $port = 8080, $address = '1
9393
if (80 == $port) {
9494
$flashUri = '0.0.0.0:843';
9595
} else {
96-
$flashUri = 8843;
96+
$flashUri = '127.0.0.1:8843';
9797
}
9898

9999
// prefer SocketServer (reactphp/socket v1.9+) over legacy \React\Socket\Server

tests/unit/AppTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
use PHPUnit\Framework\TestCase;
55
use Ratchet\App;
6+
use Ratchet\Server\IoServer;
67

78
class AppTest extends TestCase {
89
public function testCtorThrowsForInvalidLoop() {
@@ -14,4 +15,22 @@ public function testCtorThrowsForInvalidLoop() {
1415
}
1516
new App('localhost', 8080, '127.0.0.1', 'loop');
1617
}
18+
19+
public function testCtorWithoutArgumentsStartsListeningOnDefaultPorts() {
20+
if (@stream_socket_server('127.0.0.1:8080') === false || @stream_socket_server('127.0.0.1:8843') === false) {
21+
$this->markTestSkipped('Default socket port 8080 or 8843 not available or already in use');
22+
}
23+
$app = new App();
24+
25+
$ref = new \ReflectionProperty($app, '_server');
26+
$ref->setAccessible(true);
27+
$server = $ref->getValue($app);
28+
assert($server instanceof IoServer);
29+
30+
$this->assertStringMatchesFormat('%S127.0.0.1:8080', $server->socket->getAddress());
31+
$this->assertStringMatchesFormat('%S127.0.0.1:8843', $app->flashServer->socket->getAddress());
32+
33+
$server->socket->close();
34+
$app->flashServer->socket->close();
35+
}
1736
}

0 commit comments

Comments
 (0)