Refactored the init
This commit is contained in:
parent
c8ac4ef579
commit
54061d1a62
@ -94,45 +94,14 @@ namespace RBG_Server
|
|||||||
|
|
||||||
public void InitialiseClient(TcpClient client)
|
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]).
|
Progress<ProgressData> gameProgress = new Progress<ProgressData>();
|
||||||
NetworkStream stateStream = stateRetriever.GetStream();
|
Progress<ProgressData> dataProgress = new Progress<ProgressData>();
|
||||||
Task stateLoader = new Task(async () =>
|
|
||||||
{
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
Task dataLoader = InitDataLoader(dataRetriever.GetStream(), dataProgress);
|
||||||
NetworkStream dataStream = dataRetriever.GetStream();
|
Task stateLoader = InitDataLoader(stateRetriever.GetStream(), gameProgress);
|
||||||
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
|
|
||||||
|
|
||||||
dataLoader.Start();
|
dataLoader.Start();
|
||||||
stateLoader.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
|
struct ProgressData
|
||||||
|
Loading…
x
Reference in New Issue
Block a user