Skip to content

Commit

Permalink
Allow http headers to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
mbonneau committed Mar 5, 2022
1 parent da96788 commit 20563df
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"php": ">=7.1",
"voryx/thruway-common": "^1.0.0",
"reactivex/rxphp": "^2.0.4",
"rx/websocket": "^2.1.1"
"rx/websocket": "^2.1.7"
},
"extra": {
"branch-alias": {
Expand Down
4 changes: 2 additions & 2 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ final class Client

private $currentRetryCount = 0;

public function __construct(string $url, string $realm, array $options = [], Subject $webSocket = null, Observable $messages = null, Observable $session = null, ConnectorInterface $connector = null)
public function __construct(string $url, string $realm, array $options = [], Subject $webSocket = null, Observable $messages = null, Observable $session = null, ConnectorInterface $connector = null, array $headers = [])
{
$this->disposable = new CompositeDisposable();
$this->onClose = new Subject();
Expand All @@ -37,7 +37,7 @@ public function __construct(string $url, string $realm, array $options = [], Sub
$open = new Subject();
$close = new Subject();

$webSocket = $webSocket ?: new WebSocketSubject($url, ['wamp.2.json'], $open, $close, $connector);
$webSocket = $webSocket ?: new WebSocketSubject($url, ['wamp.2.json'], $open, $close, $connector, $headers);
$messages = $messages ?: $webSocket->retryWhen([$this, '_reconnect'])->singleInstance();

//When the connection opens, send a HelloMessage
Expand Down
4 changes: 2 additions & 2 deletions src/Subject/WebSocketSubject.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ final class WebSocketSubject extends Subject
private $closeObserver;
private $serializer;

public function __construct(string $url, array $protocols = [], Subject $openObserver = null, Subject $closeObserver = null, ConnectorInterface $connector = null)
public function __construct(string $url, array $protocols = [], Subject $openObserver = null, Subject $closeObserver = null, ConnectorInterface $connector = null, array $headers = [])
{
$this->openObserver = $openObserver ?? new Subject();
$this->closeObserver = $closeObserver ?? new Subject();
$this->serializer = new JsonSerializer();
$this->sendSubject = new ReplaySubject();

$this->ws = new Client($url, false, $protocols, getLoop(), $connector);
$this->ws = new Client($url, false, $protocols, getLoop(), $connector, 60000, $headers);
}

public function onNext($value)
Expand Down

0 comments on commit 20563df

Please sign in to comment.