@@ 193-213 (lines=21) @@ | ||
190 | * |
|
191 | * @return boolean |
|
192 | */ |
|
193 | public function alive(AliveOptions $options) |
|
194 | { |
|
195 | return $this->sendRequest( |
|
196 | $this->getMulticastFactory()->createSocket(self::MULTICAST_ADDRESS), |
|
197 | $this->getRequestFactory()->createAliveRequest($options), |
|
198 | function (Socket $socket) { |
|
199 | $socket->close(); |
|
200 | ||
201 | return true; |
|
202 | }, |
|
203 | function (Socket $socket, SocketException $exception) { |
|
204 | $socket->close(); |
|
205 | ||
206 | $event = new DiscoverEvent(); |
|
207 | $event->setException(new DiscoverException('Error sending alive broadcast', 0, $exception)); |
|
208 | $this->getEventDispatcher()->dispatch(DiscoverEvent::EVENT_DISCOVER_ERROR, $event); |
|
209 | ||
210 | return false; |
|
211 | } |
|
212 | ); |
|
213 | } |
|
214 | ||
215 | /** |
|
216 | * Send byebye request |
|
@@ 222-242 (lines=21) @@ | ||
219 | * |
|
220 | * @return boolean |
|
221 | */ |
|
222 | public function byebye(ByebyeOptions $options) |
|
223 | { |
|
224 | return $this->sendRequest( |
|
225 | $this->getMulticastFactory()->createSocket(self::MULTICAST_ADDRESS), |
|
226 | $this->getRequestFactory()->createByebyeRequest($options), |
|
227 | function (Socket $socket) { |
|
228 | $socket->close(); |
|
229 | ||
230 | return true; |
|
231 | }, |
|
232 | function (Socket $socket, SocketException $exception) { |
|
233 | $socket->close(); |
|
234 | ||
235 | $event = new DiscoverEvent(); |
|
236 | $event->setException(new DiscoverException('Error sending byebye broadcast', 0, $exception)); |
|
237 | $this->getEventDispatcher()->dispatch(DiscoverEvent::EVENT_DISCOVER_ERROR, $event); |
|
238 | ||
239 | return false; |
|
240 | } |
|
241 | ); |
|
242 | } |
|
243 | ||
244 | /** |
|
245 | * Send discover request |
|
@@ 310-330 (lines=21) @@ | ||
307 | * |
|
308 | * @return boolean |
|
309 | */ |
|
310 | public function update(UpdateOptions $options) |
|
311 | { |
|
312 | return $this->sendRequest( |
|
313 | $this->getMulticastFactory()->createSocket(self::MULTICAST_ADDRESS), |
|
314 | $this->getRequestFactory()->createUpdateRequest($options), |
|
315 | function (Socket $socket) { |
|
316 | $socket->close(); |
|
317 | ||
318 | return true; |
|
319 | }, |
|
320 | function (Socket $socket, SocketException $exception) { |
|
321 | $socket->close(); |
|
322 | ||
323 | $event = new DiscoverEvent(); |
|
324 | $event->setException(new DiscoverException('Error sending byebye broadcast', 0, $exception)); |
|
325 | $this->getEventDispatcher()->dispatch(DiscoverEvent::EVENT_DISCOVER_ERROR, $event); |
|
326 | ||
327 | return false; |
|
328 | } |
|
329 | ); |
|
330 | } |
|
331 | ||
332 | /** |
|
333 | * Create discover event |