Skip to content

Commit 3364d61

Browse files
committed
wamp
1 parent 3d406cc commit 3364d61

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

pkg/wamp/Tests/Spec/JsonSerializerTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Enqueue\Wamp\Tests;
3+
namespace Enqueue\Wamp\Tests\Spec;
44

55
use Enqueue\Wamp\JsonSerializer;
66
use Enqueue\Wamp\Serializer;

pkg/wamp/WampContext.php

+2-16
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,9 @@ class WampContext implements Context
3131
*/
3232
private $clientFactory;
3333

34-
public function __construct($client)
34+
public function __construct(callable $clientFactory)
3535
{
36-
if ($client instanceof Client) {
37-
$this->client = $client;
38-
} elseif (is_callable($client)) {
39-
$this->clientFactory = $client;
40-
} else {
41-
throw new \InvalidArgumentException(sprintf(
42-
'The $client argument must be either %s or callable that returns %s once called.',
43-
Client::class,
44-
Client::class
45-
));
46-
}
36+
$this->clientFactory = $clientFactory;
4737

4838
$this->setSerializer(new JsonSerializer());
4939
}
@@ -93,10 +83,6 @@ public function purgeQueue(Queue $queue): void
9383
public function close(): void
9484
{
9585
foreach ($this->clients as $client) {
96-
if (null === $client) {
97-
return;
98-
}
99-
10086
if (null === $client->getSession()) {
10187
return;
10288
}

pkg/wamp/WampSubscriptionConsumer.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function consume(int $timeout = 0): void
6161
$this->client->on('open', function (ClientSession $session) {
6262

6363
foreach ($this->subscribers as $queue => $subscriber) {
64-
$session->subscribe($queue, function ($args) use ($subscriber, $session) {
64+
$session->subscribe($queue, function ($args) use ($subscriber) {
6565
$message = $this->context->getSerializer()->toMessage($args[0]);
6666

6767
/**

0 commit comments

Comments
 (0)