mirror of
https://github.com/BoardWare-Genius/jarvis-models.git
synced 2025-12-14 00:53:25 +00:00
first commit
This commit is contained in:
25
src/main.py
Normal file
25
src/main.py
Normal 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())
|
||||
Reference in New Issue
Block a user