# Released under the MIT License. See LICENSE for details.#"""Network related data and functionality."""from__future__importannotationsimportdatetimefromtypingimportTYPE_CHECKING,Any,Annotatedfromdataclassesimportdataclass,fieldfromefro.dataclassioimportioprepped,IOAttrsifTYPE_CHECKING:pass
[docs]@ioprepped@dataclassclassServerNodeEntry:"""Information about a specific server."""zone:str# TODO: Remove soft_default after all master-servers upgraded.latlong:tuple[float,float]|Noneaddress:strport:int
[docs]@ioprepped@dataclassclassServerNodeQueryResponse:"""A response to a query about server-nodes."""# The current utc time on the master server.time:datetime.datetime# Where the master server sees the query as coming from.latlong:tuple[float,float]|Noneping_per_dist:floatmax_dist:floatdebug_log_seconds:float|None=None# If present, something went wrong, and this describes it.error:str|None=None# The set of servernodes.servers:list[ServerNodeEntry]=field(default_factory=list)
[docs]@ioprepped@dataclassclassPrivateHostingState:"""Combined state of whether we're hosting, whether we can, etc."""unavailable_error:str|None=Noneparty_code:str|None=Nonetickets_to_host_now:int=0tokens_to_host_now:int=0minutes_until_free_host:float|None=Nonefree_host_minutes_remaining:float|None=None
[docs]@ioprepped@dataclassclassPrivateHostingConfig:"""Config provided when hosting a private party."""session_type:str='ffa'playlist_name:str='Unknown'randomize:bool=Falsetutorial:bool=Falsecustom_team_names:tuple[str,str]|None=Nonecustom_team_colors:(tuple[tuple[float,float,float],tuple[float,float,float]]|None)=Noneplaylist:list[dict[str,Any]]|None=Noneexit_minutes:float=120.0exit_minutes_unclean:float=180.0exit_minutes_idle:float=10.0
[docs]@ioprepped@dataclassclassPrivatePartyConnectResult:"""Info about a server we get back when connecting."""error:str|None=Noneaddress4:str|None=Noneaddress6:str|None=Noneport:int|None=Nonepassword:str|None=None
# Docs-generation hack; import some stuff that we likely only forward-declared# in our actual source code so that docs tools can find it.fromtypingimport(Coroutine,Any,Literal,Callable,Generator,Awaitable,Sequence,Self)importasynciofromconcurrent.futuresimportFuture