Skip to content

Commit

Permalink
Merge pull request #10 from WyriHaximus/patch-2
Browse files Browse the repository at this point in the history
[WIP] End the request not the response when dispose is called
  • Loading branch information
mbonneau authored Aug 17, 2017
2 parents fc60831 + b77c511 commit a401d1c
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function _subscribe(ObserverInterface $clientObserver): DisposableInterfa
$subprotoHeader = $psr7Response->getHeader('Sec-WebSocket-Protocol');

$clientObserver->onNext(new MessageSubject(
new AnonymousObservable(function (ObserverInterface $observer) use ($response, $clientObserver) {
new AnonymousObservable(function (ObserverInterface $observer) use ($response, $request, $clientObserver) {

$response->on('data', function ($data) use ($observer) {
$observer->onNext($data);
Expand All @@ -104,12 +104,8 @@ public function _subscribe(ObserverInterface $clientObserver): DisposableInterfa
$clientObserver->onCompleted();
});

return new CallbackDisposable(function () use ($response) {
// commented this out because disposal was causing the other
// end (the request) to close also - which causes the pending messages
// to get tossed
// maybe try with $response->end()?
//$response->close();
return new CallbackDisposable(function () use ($request) {
$request->end();
});
}),
new CallbackObserver(
Expand Down

0 comments on commit a401d1c

Please sign in to comment.