1 | <?php |
||
30 | class Dispatcher implements LoggerAwareInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var Application |
||
34 | */ |
||
35 | private $application; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private $connectionPool; |
||
41 | |||
42 | /** |
||
43 | * @var ServiceClientFactory |
||
44 | */ |
||
45 | private $clientFactory; |
||
46 | |||
47 | /** |
||
48 | * @var LoggerInterface |
||
49 | */ |
||
50 | private $logger; |
||
51 | |||
52 | /** |
||
53 | * @param Application $application |
||
54 | */ |
||
55 | public function __construct(Application $application) |
||
61 | |||
62 | /** |
||
63 | * @param LoggerInterface $logger |
||
64 | * @return $this |
||
65 | */ |
||
66 | public function setLogger(LoggerInterface $logger) |
||
71 | |||
72 | /** |
||
73 | * @param bool $isDevelopment |
||
74 | * @return $this |
||
75 | */ |
||
76 | public function setDevelopmentMode($isDevelopment) |
||
81 | |||
82 | /** |
||
83 | * Returns credentials for notification service |
||
84 | * |
||
85 | * @param string $serviceName |
||
86 | * @return array |
||
87 | */ |
||
88 | private function getServiceCredentials($serviceName) |
||
92 | |||
93 | /** |
||
94 | * Gets a service client connection by service name |
||
95 | * |
||
96 | * @param string $serviceName |
||
97 | * @return ServiceClientInterface |
||
98 | */ |
||
99 | public function getConnection($serviceName) |
||
107 | |||
108 | /** |
||
109 | * Initialize service client connection by service name |
||
110 | * |
||
111 | * @param string $serviceName |
||
112 | * @return $this |
||
113 | */ |
||
114 | public function initConnection($serviceName) |
||
122 | |||
123 | /** |
||
124 | * Creates a feedback service connection |
||
125 | * |
||
126 | * @param string $serviceName |
||
127 | * @return ServiceClientInterface |
||
128 | */ |
||
129 | private function createFeedbackConnection($serviceName) |
||
134 | |||
135 | /** |
||
136 | * Tries to connect and send a message to notification service |
||
137 | * |
||
138 | * @param MessageInterface $message |
||
139 | * @return bool |
||
140 | * @throws Zbox\UnifiedPush\Exception\InvalidRecipientException |
||
141 | * @throws Zbox\UnifiedPush\Exception\DispatchMessageException |
||
142 | * @throws Zbox\UnifiedPush\Exception\MalformedNotificationException |
||
143 | */ |
||
144 | private function sendMessage(MessageInterface $message) |
||
175 | |||
176 | /** |
||
177 | * Tries to dispatch all messages to notification service |
||
178 | * |
||
179 | * @return bool |
||
180 | * @throws Zbox\UnifiedPush\Exception\ClientException |
||
181 | * @throws Zbox\UnifiedPush\Exception\RuntimeException |
||
182 | * @throws \Exception |
||
183 | */ |
||
184 | public function dispatch() |
||
215 | |||
216 | /** |
||
217 | * Tries to connect and load feedback data |
||
218 | * |
||
219 | * @return $this |
||
220 | * @throws RuntimeException |
||
221 | * @throws \Exception |
||
222 | */ |
||
223 | public function loadFeedback() |
||
252 | } |
||
253 |