def main(host, port): """Main program. Arguments: - `port`: listenning port """ # initiate the main queue used by client-connected thread to send data to the # main server thread. dana_queue = Queue.Queue() # launch the main Dana loop in a separate thread dana = Dana(dana_queue) dana.start() print('Dana thread launched') # launch network listnening (blocking call waiting for stopping of the network engine) network.connection_start(dana_queue, host=host, port=port) dana.shutdown = True dana.join() print("Dana end")
if __name__ == '__main__': # command line argument management if len(sys.argv) >= 4: nickname = sys.argv[1] host = sys.argv[2] port = int(sys.argv[3]) elif len(sys.argv) == 3: host = 'localhost' nickname = sys.argv[1] port = int(sys.argv[2]) elif len(sys.argv) == 2: host = 'localhost' port = 1337 nickname = sys.argv[1] else: host = 'localhost' port = 1337 nickname = raw_input('Veuillez indiquer votre nickname : ') # queues initialization: communication between network threads and game logic thread (which is in render) send_queue = Queue.Queue() receive_queue = Queue.Queue() # network connection network.connection_start((host,port), send_queue, receive_queue) print('network engine is running') # render's operations have to be in the main thread. display = render.Render(send_queue, receive_queue, '../shared/village.map', nickname) display.run()
# command line argument management if len(sys.argv) >= 4: nickname = sys.argv[1] host = sys.argv[2] port = int(sys.argv[3]) elif len(sys.argv) == 3: host = 'localhost' nickname = sys.argv[1] port = int(sys.argv[2]) elif len(sys.argv) == 2: host = 'localhost' port = 1337 nickname = sys.argv[1] else: host = 'localhost' port = 1337 nickname = raw_input('Veuillez indiquer votre nickname : ') # queues initialization: communication between network threads and game logic thread (which is in render) send_queue = Queue.Queue() receive_queue = Queue.Queue() # network connection network.connection_start((host, port), send_queue, receive_queue) print('network engine is running') # render's operations have to be in the main thread. display = render.Render(send_queue, receive_queue, '../shared/village.map', nickname) display.run()