Skip to content

Commit

Permalink
Fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
VirxEC committed Jul 20, 2024
1 parent 99c721c commit 8381c07
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions RLBotCS/Server/FlatBuffersSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,9 @@ private async Task HandleClientMessages()

public void BlockingRun()
{
Task incomingMessagesTask = new Task(async () =>
Task incomingMessagesTask = Task.Run(async () =>
{
Console.WriteLine("Starting incoming messages task.");
try
{
await HandleIncomingMessages();
Expand All @@ -276,10 +277,10 @@ public void BlockingRun()
Logger.LogError($"Error while handling incoming messages: {e}");
}
});
incomingMessagesTask.Start();

Task clientMessagesTask = new Task(async () =>
Task clientMessagesTask = Task.Run(async () =>
{
Console.WriteLine("Starting client messages task.");
try
{
await HandleClientMessages();
Expand All @@ -289,14 +290,14 @@ public void BlockingRun()
Logger.LogError($"Error while handling client messages: {e}");
}
});
clientMessagesTask.Start();

Task.WhenAny(incomingMessagesTask, clientMessagesTask).Wait();
}

public void Cleanup()
{
// try to politely close the connection
Logger.LogInformation($"Closing session {_clientId}.");
try
{
TypedPayload msg =
Expand Down

0 comments on commit 8381c07

Please sign in to comment.