-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.py
35 lines (29 loc) · 1013 Bytes
/
server.py
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
35
import tcpserver
import webserver
import threading
import signal
class TCPThread(threading.Thread):
def __init__(self, game_data, game_data_lock):
threading.Thread.__init__(self)
self.game_data = game_data
self.game_data_lock = game_data_lock
def run(self):
tcpserver.main(self.game_data, self.game_data_lock)
class WebThread(threading.Thread):
def __init__(self, game_data, game_data_lock):
threading.Thread.__init__(self)
self.game_data = game_data
self.game_data_lock = game_data_lock
def run(self):
webserver.main(self.game_data, self.game_data_lock)
if __name__ == '__main__':
from gamedata import GameData
game_data = GameData('PlanetWars')
game_data_lock = threading.Lock()
try:
tcpthread = TCPThread(game_data, game_data_lock)
tcpthread.start()
webthread = WebThread(game_data, game_data_lock)
webthread.start()
except KeyboardInterrupt:
pass