def __init__( self ): self.queue = queue.Queue() self.running = True self.database = database.Database() self.thread_lock = threading.Lock() self.update_thread = threading.Thread( target=self.update ) self.update_thread.start()
lobbies = { } # key = lobby id in db, value is dict of lobby connections key socket, value connection lobbies_start_times = { } # key = lobby id value if > 0 start time else not enough players # set up terminate_signal = signal_handler.SignalHandler() Global.setup(conf) DEBUG.LOGS.init() DEBUG.LOGS.set_log_to_file(message=True, warning=True, error=True, fatal=True) database = db.Database() # register the host into the database # wait for the sql server to come online while not database.database.test_connection(): time.sleep(5) lobby_host_id = database.add_lobby_host(config.get("internal_host")) # bind message functions message.Message.bind_action('&', Common.actions.processes_ping) message.Message.bind_action('?', client_status) message.Message.bind_action('i', process_client_identity) message.Message.bind_action('m', process_message) # setup socket and bind to accept client socket
import time print = DEBUG.LOGS.print # override python print with my own. config = Global.GlobalConfig Global.setup() host = config.get("internal_host") # socket.gethostname() # "DESKTOP-S8CVUEK" port = 8223 connected = False DEBUG.LOGS.init() DEBUG.LOGS.set_log_to_file(error=False) db = database.Database() # what for sql to come online while not db.database.test_connection(): time.sleep( 3 ) # try every 10 seconds time.sleep( 1.1 ) # we'll just wait a lil longer befor adding to the db db.database.insert_row("games", ["available", "host"], [True, host]) print (">-----", db.database.select_from_table( "games", ["host"] ) ) active_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) active_socket.bind( (host, port) ) active_socket.listen( 99 )