Refactored the init

This commit is contained in:
Brychan Dempsey 2021-10-17 12:48:34 +13:00
parent c8ac4ef579
commit 54061d1a62

View File

@ -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<ProgressData> gameProgress = new Progress<ProgressData>();
Progress<ProgressData> dataProgress = new Progress<ProgressData>();
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 [<uint32, length>, <byte command>]
// 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