|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
/* |
|
6
|
|
|
* This file is part of the Superdesk Web Publisher Core Bundle. |
|
7
|
|
|
* |
|
8
|
|
|
* Copyright 2018 Sourcefabric z.ú. and contributors. |
|
9
|
|
|
* |
|
10
|
|
|
* For the full copyright and license information, please see the |
|
11
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
|
12
|
|
|
* |
|
13
|
|
|
* @copyright 2018 Sourcefabric z.ú |
|
14
|
|
|
* @license http://www.superdesk.org/license |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace SWP\Bundle\CoreBundle\WebSocket\Topic; |
|
18
|
|
|
|
|
19
|
|
|
use Gos\Bundle\WebSocketBundle\Router\WampRequest; |
|
20
|
|
|
use Gos\Bundle\WebSocketBundle\Topic\PushableTopicInterface; |
|
21
|
|
|
use Gos\Bundle\WebSocketBundle\Topic\TopicInterface; |
|
22
|
|
|
use Ratchet\ConnectionInterface; |
|
23
|
|
|
use Ratchet\Wamp\Topic; |
|
24
|
|
|
|
|
25
|
|
|
final class PackageTopic extends AbstractSecuredTopic implements TopicInterface, PushableTopicInterface |
|
26
|
|
|
{ |
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
|
|
public function onSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request) |
|
31
|
|
|
{ |
|
32
|
|
|
$topic->broadcast(['msg' => sprintf('%d connected to %s', $connection->resourceId, $topic->getId())]); |
|
|
|
|
|
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {@inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
|
|
public function onUnSubscribe(ConnectionInterface $connection, Topic $topic, WampRequest $request) |
|
39
|
|
|
{ |
|
40
|
|
|
$topic->broadcast(['msg' => sprintf('%d connected to %s', $connection->resourceId, $topic->getId())]); |
|
|
|
|
|
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
/** |
|
44
|
|
|
* {@inheritdoc} |
|
45
|
|
|
*/ |
|
46
|
|
|
public function onPublish(ConnectionInterface $connection, Topic $topic, WampRequest $request, $event, array $exclude, array $eligible) |
|
47
|
|
|
{ |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* {@inheritdoc} |
|
52
|
|
|
*/ |
|
53
|
|
|
public function onPush(Topic $topic, WampRequest $request, $data, $provider) |
|
54
|
|
|
{ |
|
55
|
|
|
$topic->broadcast($data); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* {@inheritdoc} |
|
60
|
|
|
*/ |
|
61
|
|
|
public function getName() |
|
62
|
|
|
{ |
|
63
|
|
|
return 'swp.package'; |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: