blob: 6b7111de94043e4df948e8e1a9038fb11d737a66 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
#!/usr/bin/env python3
""" Entry point to play the game. """
import argparse
import asyncio
import logging
from websockets.server import serve
from swiftstory.game_manager import GameManager
from swiftstory.interface.ws import WebsocketsInterface
def main():
""" Entry point: we create the game manager and start the Websockets
server. """
parser = argparse.ArgumentParser()
parser.add_argument('--listen', type=str, default='0.0.0.0')
parser.add_argument('--port', type=int, default=1236)
args = vars(parser.parse_args())
logging.basicConfig(level=logging.INFO)
ws_interface = WebsocketsInterface(GameManager())
start_server = serve(ws_interface.connection_handler,
args['listen'], args['port'])
asyncio.get_event_loop().run_until_complete(start_server)
asyncio.get_event_loop().run_forever()
if __name__ == '__main__':
main()
|