Enable remote peers to find and connect to this peer.
(peer=None)
| 328 | |
| 329 | |
| 330 | async def make_discoverable(peer=None): |
| 331 | """Enable remote peers to find and connect to this peer.""" |
| 332 | logger.debug('Enter peer discoverable.') |
| 333 | logger.debug('Before _is_shutting_down') |
| 334 | global _is_shutting_down |
| 335 | logger.debug('Making peer discoverable.') |
| 336 | while not _is_shutting_down: |
| 337 | logger.debug('Discovery loop.') |
| 338 | logger.debug('peer status: {}', peer) |
| 339 | try: |
| 340 | if not peer or peer.destroyed: |
| 341 | logger.info('Peer destroyed. Will create a new peer.') |
| 342 | peer = await pnp_service_connect() |
| 343 | elif peer.open: |
| 344 | await join_peer_room(peer=peer) |
| 345 | elif peer.disconnected: |
| 346 | logger.info('Peer disconnected. Will try to reconnect.') |
| 347 | await peer.reconnect() |
| 348 | else: |
| 349 | logger.info('Peer still establishing connection. {}', peer) |
| 350 | except Exception as e: |
| 351 | logger.exception('Error while trying to join local peer room. ' |
| 352 | 'Will retry in a few moments. ' |
| 353 | 'Error: \n{}', e) |
| 354 | if peer and not peer.destroyed: |
| 355 | # something is not right with the connection to the server |
| 356 | # lets start a fresh peer connection |
| 357 | logger.info('Peer connection was corrupted. Detroying peer.') |
| 358 | await peer.destroy() |
| 359 | peer = None |
| 360 | logger.debug('peer status after destroy: {}', peer) |
| 361 | await asyncio.sleep(3) |
| 362 | |
| 363 | |
| 364 | def _config_logger(): |
no test coverage detected