mirror of
https://github.com/KevinMidboe/delugeClient.git
synced 2025-10-29 12:00:13 +00:00
Restructured project files.
Moved all packages files to delugeClient folder. Split contents of deluge_cli to __main__, utils, deluge & torrent. Config default changed from config.ini --> delugeClient/default_config.ini. Setup.py updated with new entry.
This commit is contained in:
27
delugeClient/deluge_socket.py
Normal file
27
delugeClient/deluge_socket.py
Normal file
@@ -0,0 +1,27 @@
|
||||
import asyncio
|
||||
import datetime
|
||||
import random
|
||||
import websockets
|
||||
|
||||
async def hello(websocket, path):
|
||||
name = await websocket.recv()
|
||||
print(f"< {name}")
|
||||
|
||||
greeting = f"Hello {name}, welcome to the world of websockets!"
|
||||
|
||||
await websocket.send(greeting)
|
||||
print(f"> {greeting}")
|
||||
|
||||
async def time(websocket, path):
|
||||
while True:
|
||||
now = datetime.datetime.utcnow().isoformat() + 'Z'
|
||||
await websocket.send(now)
|
||||
await asyncio.sleep(1)
|
||||
|
||||
|
||||
serve_hello = websockets.serve(hello, '0.0.0.0', 8765)
|
||||
serve_time = websockets.serve(time, '0.0.0.0', 5678)
|
||||
|
||||
asyncio.get_event_loop().run_until_complete(serve_hello)
|
||||
asyncio.get_event_loop().run_until_complete(serve_time)
|
||||
asyncio.get_event_loop().run_forever()
|
||||
Reference in New Issue
Block a user