Archived
30 lines
569 B
Python
30 lines
569 B
Python
#!/usr/bin/env python
|
|
import asyncio
|
|
from game import Game
|
|
|
|
from netcode.ws_server import WebSocketServerProtocol
|
|
from netcode import WSServer
|
|
from controller import Client
|
|
|
|
gameServer = WSServer()
|
|
hero_game = Game()
|
|
hero_game.broadcast = gameServer.broadcast
|
|
|
|
|
|
playerServer = WSServer()
|
|
|
|
|
|
async def handler(websocket: WebSocketServerProtocol):
|
|
client = Client(websocket)
|
|
await client.listen()
|
|
|
|
|
|
playerServer.message_callbacks.append(handler)
|
|
|
|
|
|
async def main():
|
|
await asyncio.gather(gameServer.serve(), playerServer.serve(port=8766))
|
|
|
|
|
|
asyncio.run(main())
|