Provides decorator to announce the presence of a server to a host machine.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

49 lines
1.0 KiB

import argparse
import asyncio
import socketio
sio = socketio.AsyncClient()
@sio.event
async def connect():
print("Connected to the host!")
@sio.event
async def disconnect():
print("Disconnected from the host.")
@sio.event
async def heartbeat():
print("Received heartbeat from the host.")
async def main(host_ip, host_port):
print(f"Connecting to host at {host_ip}:{host_port}")
await sio.connect(f"http://{host_ip}:{host_port}")
await sio.wait()
def start_client(host_ip="0.0.0.0", host_port=4999):
asyncio.run(main(host_ip, host_port))
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Start announce_server client.")
parser.add_argument(
"--host-ip",
type=str,
default="127.0.0.1",
help="Host IP address (default: 127.0.0.1)",
)
parser.add_argument(
"--host-port", type=int, default=4999, help="Host port number (default: 4999)"
)
args = parser.parse_args()
start_client(args.host_ip, args.host_port)