first commit

This commit is contained in:
Dan Chen
2024-03-18 11:33:39 +08:00
commit 813e584b97
11 changed files with 258 additions and 0 deletions

25
src/main.py Normal file
View File

@ -0,0 +1,25 @@
import asyncio
import websockets
from websockets.server import serve
from websockets.legacy.server import WebSocketServerProtocol
from connection.connection import ConnectionContext
async def echo(websocket: WebSocketServerProtocol):
connection = ConnectionContext()
while True:
try:
message = await websocket.recv()
except websockets.ConnectionClosedOK:
break
connection.handle(message)
async def main():
async with serve(echo, "localhost", 8765):
await asyncio.Future()
if __name__ == "__main__":
asyncio.run(main())