-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
35 lines (32 loc) · 961 Bytes
/
main.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
from telnetServer import TelnetServer
from player import Player
from mud import Mud
from worker import Worker
from busevent import BusEvent
from mysql import Mysql
from callback import Callback
import time
def loadBroadcasts(mysql, callbacks, worker):
for i in mysql.getEntry("select time_interval, message from broadcast"):
if not i:
return
callbacks.register(i["time_interval"], worker.broadcast, i["message"])
server = TelnetServer("0.0.0.0", 23)
mud = Mud("data.xml")
bus = BusEvent()
mysql = Mysql('localhost', 'mud', 'root', '')
if not mysql.ok:
print("Error while connecting to mysql")
exit()
if not mud.begin:
print("Error while loading data for mud")
exit()
worker = Worker(mud, server, bus, mysql)
callbacks = Callback()
loadBroadcasts(mysql, callbacks, worker)
while server.update():
worker.connections()
worker.disconnections()
worker.messages()
callbacks.run()
time.sleep(0.2)