1 | <?php |
||
14 | class Subscriber implements SubscriberContract |
||
15 | { |
||
16 | /** |
||
17 | * The logger instance. |
||
18 | * |
||
19 | * @var LoggerContract |
||
20 | */ |
||
21 | protected $logger; |
||
22 | |||
23 | /** |
||
24 | * The config repository instance. |
||
25 | * |
||
26 | * @var RepositoryContract |
||
27 | */ |
||
28 | protected $config; |
||
29 | |||
30 | /** |
||
31 | * The dispatcher instance. |
||
32 | * |
||
33 | * @var DispatcherContract |
||
34 | */ |
||
35 | protected $dispatcher; |
||
36 | |||
37 | /** |
||
38 | * Create a new subscriber instance. |
||
39 | * |
||
40 | * @param LoggerContract $logger |
||
41 | * @param RepositoryContract $config |
||
42 | * @param DispatcherContract $dispatcher |
||
43 | */ |
||
44 | 16 | public function __construct( |
|
53 | |||
54 | /** |
||
55 | * Handle the connect event. |
||
56 | * |
||
57 | * @param WebSocket $webSocket |
||
58 | * |
||
59 | * @return void |
||
60 | */ |
||
61 | 2 | public function onConnect(WebSocket $webSocket): void |
|
74 | |||
75 | /** |
||
76 | * Handle the message event. |
||
77 | * |
||
78 | * @param MessageContract $message |
||
79 | * |
||
80 | * @return void |
||
81 | */ |
||
82 | 4 | public function onMessage(MessageContract $message): void |
|
96 | |||
97 | /** |
||
98 | * Handle the disconnect event. |
||
99 | * |
||
100 | * @param int|null $code |
||
101 | * @param string|null $reason |
||
102 | * |
||
103 | * @return void |
||
104 | */ |
||
105 | 2 | public function onDisconnect(int $code = null, string $reason = null): void |
|
109 | |||
110 | /** |
||
111 | * Handle the error event. |
||
112 | * |
||
113 | * @param Exception $exception |
||
114 | * |
||
115 | * @return void |
||
116 | */ |
||
117 | 2 | public function onError(Exception $exception): void |
|
121 | |||
122 | /** |
||
123 | * Register the listeners for the subscriber. |
||
124 | * |
||
125 | * @param PromiseContract $connection |
||
126 | */ |
||
127 | 2 | public function subscribe(PromiseContract $connection): void |
|
131 | } |
||
132 |