MCPcopy Create free account
hub / github.com/battlecode/battlecode-2018 / start_viewer_server

Function start_viewer_server

battlecode-manager/server.py:715–738  ·  view source on GitHub ↗

Start a socket server for the players to connect to Args: port: port to connect to viewer on game: The game information that is being run use_docker bool: whether to use docker or not Return: server_thread: The connection so it can be closed by parent

(port: int, game: Game)

Source from the content-addressed store, hash-verified

713 return server
714
715def start_viewer_server(port: int, game: Game) -> socketserver.BaseServer:
716 '''
717 Start a socket server for the players to connect to
718 Args:
719 port: port to connect to viewer on
720
721 game: The game information that is being run
722
723 use_docker bool: whether to use docker or not
724
725 Return:
726 server_thread: The connection so it can be closed by parent functions at
727 the appropriate time
728 '''
729
730 # Create handler for mangaing each connections to server
731 receive_handler = create_receive_handler(game, {}, False, False)
732
733 # Start server
734 server = socketserver.ThreadingTCPServer(('localhost', port), receive_handler)
735 server_thread = threading.Thread(target=server.serve_forever, daemon=True)
736 server_thread.start()
737
738 return server

Callers

nothing calls this directly

Calls 2

create_receive_handlerFunction · 0.85
startMethod · 0.45

Tested by

no test coverage detected