Skip to content

Commit b86d04e

Browse files
committed
Merge branch '0.3-prep'
2 parents 7a4c92c + 5b8934f commit b86d04e

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

README.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Pawl
22

33
[![Autobahn Testsuite](https://img.shields.io/badge/Autobahn-passing-brightgreen.svg)](http://socketo.me/reports/pawl/index.html)
4+
[![Build Status](https://travis-ci.org/ratchetphp/Pawl.svg?branch=master)](https://travis-ci.org/ratchetphp/Pawl)
45

56
An asynchronous WebSocket client in PHP
67

@@ -59,7 +60,11 @@ A more in-depth example using explicit interfaces: Requesting sub-protocols, and
5960
require __DIR__ . '/vendor/autoload.php';
6061

6162
$loop = React\EventLoop\Factory::create();
62-
$connector = new Ratchet\Client\Connector($loop);
63+
$reactConnector = new React\Socket\Connector($loop, [
64+
'dns' => '8.8.8.8',
65+
'timeout' => 10
66+
]);
67+
$connector = new Ratchet\Client\Connector($loop, $reactConnector);
6368

6469
$connector('ws://127.0.0.1:9000', ['protocol1', 'subprotocol2'], ['Origin' => 'http://localhost'])
6570
->then(function(Ratchet\Client\WebSocket $conn) {

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"php": ">=5.4"
1414
, "react/socket": "^1.0 || ^0.8 || ^0.7"
1515
, "evenement/evenement": "^3.0 || ^2.0"
16-
, "ratchet/rfc6455": "^0.2.2"
16+
, "ratchet/rfc6455": "^0.2.3"
1717
}
1818
, "require-dev": {
1919
"phpunit/phpunit": "~4.8"

src/Connector.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use React\Socket\ConnectorInterface;
77
use React\Promise\Deferred;
88
use React\Promise\RejectedPromise;
9+
use Psr\Http\Message\RequestInterface;
910
use GuzzleHttp\Psr7 as gPsr;
1011

1112
class Connector {
@@ -104,6 +105,7 @@ public function __invoke($url, array $subProtocols = [], array $headers = []) {
104105
* @param string $url
105106
* @param array $subProtocols
106107
* @param array $headers
108+
* @throws \InvalidArgumentException
107109
* @return \Psr\Http\Message\RequestInterface
108110
*/
109111
protected function generateRequest($url, array $subProtocols, array $headers) {
@@ -121,9 +123,9 @@ protected function generateRequest($url, array $subProtocols, array $headers) {
121123
$uri = $uri->withPort('wss' === $scheme ? 443 : 80);
122124
}
123125

124-
$headers += ['User-Agent' => 'Ratchet-Pawl/0.2.3'];
126+
$headers += ['User-Agent' => 'Ratchet-Pawl/0.3'];
125127

126-
$request = array_reduce(array_keys($headers), function($request, $header) use ($headers) {
128+
$request = array_reduce(array_keys($headers), function(RequestInterface $request, $header) use ($headers) {
127129
return $request->withHeader($header, $headers[$header]);
128130
}, $this->_negotiator->generateRequest($uri));
129131

src/WebSocket.php

+4-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
namespace Ratchet\Client;
33
use Evenement\EventEmitterTrait;
44
use Evenement\EventEmitterInterface;
5-
use React\Stream\DuplexStreamInterface;
5+
use React\Socket\ConnectionInterface;
66
use Psr\Http\Message\RequestInterface;
77
use Psr\Http\Message\ResponseInterface;
88
use Ratchet\RFC6455\Messaging\MessageBuffer;
@@ -27,7 +27,7 @@ class WebSocket implements EventEmitterInterface {
2727
public $response;
2828

2929
/**
30-
* @var \React\Stream\Stream
30+
* @var \React\Socket\ConnectionInterface
3131
*/
3232
protected $_stream;
3333

@@ -38,15 +38,15 @@ class WebSocket implements EventEmitterInterface {
3838

3939
/**
4040
* WebSocket constructor.
41-
* @param \React\Stream\DuplexStreamInterface $stream
41+
* @param \React\Socket\ConnectionInterface $stream
4242
* @param \Psr\Http\Message\ResponseInterface $response
4343
* @param \Psr\Http\Message\RequestInterface $request
4444
* @event message
4545
* @event pong
4646
* @event close
4747
* @event error
4848
*/
49-
public function __construct(DuplexStreamInterface $stream, ResponseInterface $response, RequestInterface $request) {
49+
public function __construct(ConnectionInterface $stream, ResponseInterface $response, RequestInterface $request) {
5050
$this->_stream = $stream;
5151
$this->response = $response;
5252
$this->request = $request;
@@ -103,13 +103,6 @@ function() use ($reusableUAException) {
103103

104104
$stream->on('data', [$streamer, 'onData']);
105105

106-
$stream->on('end', function(DuplexStreamInterface $stream) {
107-
if (is_resource($stream->stream)) {
108-
stream_socket_shutdown($stream->stream, STREAM_SHUT_RDWR);
109-
stream_set_blocking($stream->stream, false);
110-
}
111-
});
112-
113106
$stream->on('close', function () {
114107
$close = $this->_close;
115108
$close(Frame::CLOSE_ABNORMAL, 'Underlying connection closed');

src/functions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @param array $subProtocols
99
* @param array $headers
1010
* @param LoopInterface|null $loop
11-
* @return \React\Promise\PromiseInterface
11+
* @return \React\Promise\PromiseInterface<\Ratchet\Client\WebSocket>
1212
*/
1313
function connect($url, array $subProtocols = [], $headers = [], LoopInterface $loop = null) {
1414
$loop = $loop ?: ReactFactory::create();

tests/autobahn/runner.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
require __DIR__ . '/../../vendor/autoload.php';
66

7-
define('AGENT', 'Pawl/0.2.3');
7+
define('AGENT', 'Pawl/0.3');
88

99
$loop = React\EventLoop\Factory::create();
1010

0 commit comments

Comments
 (0)