From 54061d1a62278180c6d056d0ae83302deb7f1f03 Mon Sep 17 00:00:00 2001 From: Brychan Dempsey Date: Sun, 17 Oct 2021 12:48:34 +1300 Subject: [PATCH] Refactored the init --- RBG_Server.Core/CommunicationHandler.cs | 39 +++---------------------- 1 file changed, 4 insertions(+), 35 deletions(-) diff --git a/RBG_Server.Core/CommunicationHandler.cs b/RBG_Server.Core/CommunicationHandler.cs index c25cc28..e938d8c 100644 --- a/RBG_Server.Core/CommunicationHandler.cs +++ b/RBG_Server.Core/CommunicationHandler.cs @@ -94,45 +94,14 @@ namespace RBG_Server public void InitialiseClient(TcpClient client) { - // At this point, no details about the game are loaded; we must load them from the server (to which we have already connected [no data should have been sent]). - NetworkStream stateStream = stateRetriever.GetStream(); - Task stateLoader = new Task(async () => - { - - }); - + Progress gameProgress = new Progress(); + Progress dataProgress = new Progress(); - - NetworkStream dataStream = dataRetriever.GetStream(); - Task dataLoader = new Task(async () => - { - - // At this point, the minimal amount of work required by the data thread has been done (load all thumbs) - // When an asset is needed from here, queue a load - }); - - // start the tasks; they should have + Task dataLoader = InitDataLoader(dataRetriever.GetStream(), dataProgress); + Task stateLoader = InitDataLoader(stateRetriever.GetStream(), gameProgress); dataLoader.Start(); stateLoader.Start(); - - - byte[] buffer = new byte[] {0,0,0,1,1}; - // Writing to the stream is to be considered near constant-time, but reading is non-constant. - // This application model must be synchronous, but we execute other commands before expecting our response to have arrived (it can complete at any time in that period) - stateStream.Write(buffer, 0, buffer.Length); - buffer[0] = 1; - buffer[3] = 0; - dataStream.Write(buffer, 0, buffer.Length); - // A details request is [, ] - // The response is about the same format: - var stateResponse = GetResponse(stateStream, 4); - var dataResponse = GetResponse(dataStream, 4); - // First, load the board state (low mip-map, row definitions, column definitions, zoom position etc.) - // Retrieval command for the board - // Then load the player list, and use the low mip for their sprites - // Then check each loaded image and load the med, then large, then full sprite - // Then load the low of each unused image (for quick retrieval) } struct ProgressData