# 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:Annotated[str,IOAttrs('r')]# TODO: Remove soft_default after all master-servers upgraded.latlong:Annotated[tuple[float,float]|None,IOAttrs('ll',soft_default=None)]address:Annotated[str,IOAttrs('a')]port:Annotated[int,IOAttrs('p')]
[docs]@ioprepped@dataclassclassServerNodeQueryResponse:"""A response to a query about server-nodes."""# The current utc time on the master server.time:Annotated[datetime.datetime,IOAttrs('t')]# Where the master server sees the query as coming from.latlong:Annotated[tuple[float,float]|None,IOAttrs('ll')]ping_per_dist:Annotated[float,IOAttrs('ppd')]max_dist:Annotated[float,IOAttrs('md')]debug_log_seconds:Annotated[float|None,IOAttrs('d',store_default=False)]=None# If present, something went wrong, and this describes it.error:Annotated[str|None,IOAttrs('e',store_default=False)]=None# The set of servernodes.servers:Annotated[list[ServerNodeEntry],IOAttrs('s',store_default=False)]=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:Annotated[str|None,IOAttrs('addr')]=Noneaddress6:Annotated[str|None,IOAttrs('addr6')]=Noneport:int|None=Nonepassword:str|None=None