Skip to content

Commit

Permalink
Update for amphp/socket master and amphp/http-server v2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Jul 26, 2019
1 parent eb666a3 commit 795b1a6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@
"php": ">=7.1",
"amphp/amp": "^2.0.3",
"amphp/byte-stream": "^1.5",
"amphp/http": "^1",
"amphp/http-server": "^1 || ^0.8",
"amphp/socket": "^0.10.5",
"amphp/websocket": "dev-master"
"amphp/http": "^1.2",
"amphp/http-server": "v2.x-dev as 1.0",
"amphp/socket": "dev-master as 1.0",
"amphp/websocket": "socket-1.0-dev as 1.0"
},
"require-dev": {
"amphp/artax": "^3",
"amphp/http-client": "dev-master as 4.0",
"amphp/http-server-static-content": "^1",
"amphp/http-server-router": "^1",
"amphp/log": "^1",
Expand Down
3 changes: 2 additions & 1 deletion src/Websocket.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Amp\Http\Server\ServerObserver;
use Amp\Http\Status;
use Amp\Promise;
use Amp\Socket\ResourceSocket;
use Amp\Socket\Socket;
use Amp\Success;
use Amp\Websocket\Client;
Expand Down Expand Up @@ -223,7 +224,7 @@ private function reapClient(Socket $socket, Request $request, Response $response
$client = $this->clientFactory->createClient($request, $response, $socket, $this->options, $compressionContext);

// Setting via stream API doesn't seem to work...
if (\function_exists('socket_import_stream') && \defined('TCP_NODELAY')) {
if ($socket instanceof ResourceSocket && \function_exists('socket_import_stream') && \defined('TCP_NODELAY')) {
$sock = \socket_import_stream($socket->getResource());
/** @noinspection PhpComposerExtensionStubsInspection */
@\socket_set_option($sock, \SOL_TCP, \TCP_NODELAY, 1); // error suppression for sockets which don't support the option
Expand Down
4 changes: 2 additions & 2 deletions test/WebsocketTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ public function provideHandshakes(): array
public function createMockWebsocket(): Websocket
{
$server = new HttpServer(
[$this->createMock(Server::class)],
[Socket\listen('127.0.0.1:0')],
$this->createMock(RequestHandler::class),
new NullLogger
);
Expand Down Expand Up @@ -217,7 +217,7 @@ protected function execute(callable $onConnect, Client $client): void
yield $webserver->start();

$socket = yield Socket\connect($server->getAddress());
\assert($socket instanceof Socket\ClientSocket);
\assert($socket instanceof Socket\EncryptableSocket);

$request = $this->createRequest();
yield $socket->write($this->writeRequest($request));
Expand Down

0 comments on commit 795b1a6

Please sign in to comment.