Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
themanyfaceddemon committed Jul 28, 2024
1 parent 1ff33a4 commit 391d5e5
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Code/systems/network/client_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ def __init__(self) -> None:
self._http_url: str = ""
self._socket_url: Tuple[str, int] = ("", 0)
self._session: requests.Session = requests.Session()

self._token: Optional[str] = None
self._cur_server_name: Optional[str] = None

self._socket: Optional[socket.socket] = None
self._bg_processing: bool = False
self._bg_thread: Optional[threading.Thread] = None
Expand All @@ -46,11 +49,12 @@ def check_server(self, ip: str, port: int = 5000) -> None:
response = self._session.get(f"{temp_http_url}/server/check_status", timeout=5)
response.raise_for_status()

response_data = response.json()
response_data: dict = response.json()
if response_data.get("message") == "Server is online":
server_info = response_data.get("server_info", {})
server_info: dict = response_data.get("server_info", {})
self._http_url = temp_http_url
self._socket_url = (ip, server_info.get("socket_port"))
self._cur_server_name = server_info.get("server_name")

def download_server_content(self, progress_callback=None) -> None:
try:
Expand All @@ -61,7 +65,7 @@ def download_server_content(self, progress_callback=None) -> None:
raise RuntimeError(f"Error during HTTP request: {e}")

archive_path = "content.zip"
content_dir = os.path.join(ROOT_PATH, 'Content', "Servers", self._http_url)
content_dir = os.path.join(ROOT_PATH, 'Content', "Servers", self._cur_server_name)
total_size = int(response.headers.get('content-length', 0))
downloaded_size = 0

Expand Down

0 comments on commit 391d5e5

Please sign in to comment.