MCPcopy Create free account
hub / github.com/ddnet/ddnet / Server

Class Server

scripts/integration_test.py:467–506  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

465
466
467class Server(Runnable):
468 def __init__(self, test_env, extra_args=[]): # noqa: B006 mutable-default-arguments
469 name = f"server{test_env.num_servers}"
470 self.fifo_name, self.fifo_path = fifo_name_path(test_env, name)
471 # Delay opening the FIFO until the server has started, because it will
472 # block.
473 self.fifo = None
474 super().__init__(
475 test_env,
476 name,
477 [
478 test_env.ddnet_server,
479 f"sv_input_fifo {self.fifo_name}",
480 "sv_register 0",
481 ]
482 + extra_args,
483 )
484 test_env.num_servers += 1
485
486 def command(self, command):
487 if self.fifo is None:
488 self.fifo = open_fifo(self.fifo_path)
489 self.fifo.write(f"{command}\n")
490
491 def next_event(self, timeout_id):
492 event = super().next_event(timeout_id)
493 if isinstance(event, Log):
494 if event.line.startswith("server: using port "):
495 self.port = int(event.line[len("server: using port ") :])
496 elif event.line.startswith("server: | rcon password: '"):
497 _, self.rcon_password, _ = event.line.split("'")
498 elif event.line.startswith("teehistorian: recording to '"):
499 _, self.teehistorian_filename, _ = event.line.split("'")
500 return event
501
502 def exit(self):
503 self.command("shutdown")
504
505 def wait_for_startup(self, timeout=5):
506 self.wait_for_log_prefix("server: version", timeout=timeout)
507
508
509class Mastersrv(Runnable):

Callers 1

serverMethod · 0.70

Calls

no outgoing calls

Tested by 1

serverMethod · 0.56