1 | <?php |
||
30 | class Dispatcher implements LoggerAwareInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var Application |
||
34 | */ |
||
35 | private $application; |
||
36 | |||
37 | /** |
||
38 | * @var NotificationBuilder |
||
39 | */ |
||
40 | private $notificationBuilder; |
||
41 | |||
42 | /** |
||
43 | * @var array |
||
44 | */ |
||
45 | private $connectionPool; |
||
46 | |||
47 | /** |
||
48 | * @var ServiceClientFactory |
||
49 | */ |
||
50 | private $clientFactory; |
||
51 | |||
52 | /** |
||
53 | * @var LoggerInterface |
||
54 | */ |
||
55 | private $logger; |
||
56 | |||
57 | /** |
||
58 | * @param Application $application |
||
59 | * @param ServiceClientFactory $clientFactory |
||
60 | * @param NotificationBuilder $notificationBuilder |
||
61 | */ |
||
62 | public function __construct( |
||
73 | |||
74 | /** |
||
75 | * @param LoggerInterface $logger |
||
76 | * @return $this |
||
77 | */ |
||
78 | public function setLogger(LoggerInterface $logger) |
||
83 | |||
84 | /** |
||
85 | * @param bool $isDevelopment |
||
86 | * @return $this |
||
87 | */ |
||
88 | public function setDevelopmentMode($isDevelopment) |
||
93 | |||
94 | /** |
||
95 | * Returns credentials for notification service |
||
96 | * |
||
97 | * @param string $serviceName |
||
98 | * @return array |
||
99 | */ |
||
100 | private function getServiceCredentials($serviceName) |
||
104 | |||
105 | /** |
||
106 | * Gets a service client connection by service name |
||
107 | * |
||
108 | * @param string $serviceName |
||
109 | * @return ServiceClientInterface |
||
110 | */ |
||
111 | public function getConnection($serviceName) |
||
119 | |||
120 | /** |
||
121 | * Initialize service client connection by service name |
||
122 | * |
||
123 | * @param string $serviceName |
||
124 | * @return $this |
||
125 | */ |
||
126 | public function initConnection($serviceName) |
||
134 | |||
135 | /** |
||
136 | * Creates a feedback service connection |
||
137 | * |
||
138 | * @param string $serviceName |
||
139 | * @return ServiceClientInterface |
||
140 | */ |
||
141 | private function createFeedbackConnection($serviceName) |
||
146 | |||
147 | /** |
||
148 | * Tries to connect and send a message to notification service |
||
149 | * |
||
150 | * @return bool |
||
151 | * @throws Zbox\UnifiedPush\Exception\InvalidRecipientException |
||
152 | * @throws Zbox\UnifiedPush\Exception\DispatchMessageException |
||
153 | * @throws Zbox\UnifiedPush\Exception\MalformedNotificationException |
||
154 | */ |
||
155 | private function sendNotifications() |
||
182 | |||
183 | /** |
||
184 | * Tries to dispatch all messages to notification service |
||
185 | * |
||
186 | * @return bool |
||
187 | * @throws Zbox\UnifiedPush\Exception\ClientException |
||
188 | * @throws Zbox\UnifiedPush\Exception\RuntimeException |
||
189 | * @throws \Exception |
||
190 | */ |
||
191 | public function dispatch() |
||
225 | |||
226 | /** |
||
227 | * Tries to connect and load feedback data |
||
228 | * |
||
229 | * @return $this |
||
230 | * @throws RuntimeException |
||
231 | * @throws \Exception |
||
232 | */ |
||
233 | public function loadFeedback() |
||
262 | } |
||
263 |