Title here
Summary here
A Networking Function is reusable function designed to perform a specific task or operation related to Networking.
peer_get_id_async()
Get the id of the current client.
str
representing the id of the peer.
id = await peer_get_id_async()
print(id)
peer_create_connection_async(peerId: str)
Create a connection with destination client identified by peerId asynchronously
peerId (str)
: Peer Id of the destination client to connect with.str
representing the id of the connection.
id = await input_async("Peer Id")
conn = await peer_create_connection_async(id)
print(conn)
peer_send(conn: str, data: str)
Function to send data to the destination peer.
con (str)
: A str
representing the connnection id.data (str)
: A str
representing the data to send to the destination peer.
id = await input_async("Peer Id")
conn = await peer_create_connection_async(id)
print(conn)
peer_send(conn, "data to send")
peer_recive(data: str)
To recive data the destination peer must declare a function called peer_receive(data: str)
.
import asyncio
def peer_recive(data):
print(data)
await asyncio.sleep(10000)