MCPcopy Create free account
hub / github.com/ambianic/peerfetch / pnp_service_connect

Function pnp_service_connect

python/src/peerfetch/proxy.py:297–327  ·  view source on GitHub ↗

Create a Peer instance and register with PnP signaling server.

()

Source from the content-addressed store, hash-verified

295
296
297async def pnp_service_connect() -> Peer:
298 """Create a Peer instance and register with PnP signaling server."""
299 # Create own peer object with connection to shared PeerJS server
300 logger.info('creating peer')
301 # If we already have an assigned peerId, we will reuse it forever.
302 # We expect that peerId is crypto secure. No need to replace.
303 # Unless the user explicitly requests a refresh.
304 global savedPeerId
305 global config
306 logger.info('last saved savedPeerId {}', savedPeerId)
307 new_token = util.randomToken()
308 logger.info('Peer session token {}', new_token)
309
310
311 options = PeerOptions(
312 host=config['signaling_server'],
313 port=config['port'],
314 secure=config['secure'],
315 token=new_token,
316 config=RTCConfiguration(
317 iceServers=[RTCIceServer(**srv) for srv in config['ice_servers']]
318 )
319 )
320 peer = Peer(id=savedPeerId, peer_options=options)
321 logger.info('pnpService: peer created with id {} , options: {}',
322 peer.id,
323 peer.options)
324 await peer.start()
325 logger.info('peer activated')
326 _setPnPServiceConnectionHandlers(peer)
327 return peer
328
329
330async def make_discoverable(peer=None):

Callers 1

make_discoverableFunction · 0.85

Calls 1

Tested by

no test coverage detected