1 | <?php |
||
26 | class WebSocketClient |
||
27 | { |
||
28 | /** |
||
29 | * @var Url |
||
30 | */ |
||
31 | private $url; |
||
32 | |||
33 | /** |
||
34 | * @var array |
||
35 | */ |
||
36 | private $config; |
||
37 | |||
38 | /** |
||
39 | * @var Connection |
||
40 | */ |
||
41 | private $connection; |
||
42 | |||
43 | /** |
||
44 | * @var ConnectorFactoryInterface |
||
45 | */ |
||
46 | private $connectorFactory; |
||
47 | |||
48 | /** |
||
49 | * @var LoopInterface |
||
50 | */ |
||
51 | private $loop; |
||
52 | |||
53 | /** |
||
54 | * @var MessageProcessor |
||
55 | */ |
||
56 | private $messageProcessor; |
||
57 | |||
58 | public function __construct(string $url, array $config = [], ConnectorFactoryInterface $connectorFactory = null) |
||
64 | |||
65 | /** |
||
66 | * @param MessageHandlerInterface $handler |
||
67 | * @throws \Exception |
||
68 | */ |
||
69 | public function start(MessageHandlerInterface $handler) |
||
85 | |||
86 | /** |
||
87 | * @param array $config |
||
88 | * @return self |
||
89 | */ |
||
90 | public function setConfig(array $config = []) |
||
102 | |||
103 | /** |
||
104 | * Creates a connector factory with the given configuration if none given in the constructor. |
||
105 | * |
||
106 | * @return ConnectorFactoryInterface |
||
107 | */ |
||
108 | private function getConnectorFactory() : ConnectorFactoryInterface |
||
126 | |||
127 | /** |
||
128 | * @return LoopInterface |
||
129 | */ |
||
130 | private function getLoop() : LoopInterface |
||
138 | |||
139 | /** |
||
140 | * @return MessageProcessor |
||
141 | */ |
||
142 | private function getMessageProcessor(): MessageProcessor |
||
161 | } |
||
162 |