Skip to content

Commit

Permalink
fix(Server): 🐛 fix server AddPlayer sending being stuck
Browse files Browse the repository at this point in the history
  • Loading branch information
asdawej committed Apr 13, 2024
1 parent 57ac000 commit e1c6c12
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
4 changes: 3 additions & 1 deletion CAPI/python_exp/PyAPI/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ def __LoadBuffer(self, message: Message2Clients.MessageToClient) -> None:
self.__bufferState.gameInfo = Proto2THUAI7.Protobuf2THUAI7GameInfo(message.all_message)

self.__LoadBufferSelf(message)
if self.__playerType == THUAI7.Ship and isinstance(self.__bufferState.self, None):
return
for item in message.obj_message:
self.__LoadBufferCase(item)
if Setting.Asynchronous():
Expand All @@ -347,7 +349,7 @@ def __LoadBuffer(self, message: Message2Clients.MessageToClient) -> None:
self.__cvBuffer.notify()

def __LoadBufferSelf(self, message: Message2Clients.MessageToClient) -> None:
if self.__playerID != 0:
if self.__playerType == THUAI7.PlayerType.Ship:
for item in message.obj_message:
if item.WhichOneof("message_of_obj") == "ship_message":
if item.ship_message.player_id == self.__playerID:
Expand Down
42 changes: 20 additions & 22 deletions logic/Server/RpcServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -186,34 +186,32 @@ public override async Task AddPlayer(PlayerMsg request, IServerStreamWriter<Mess
semaDict0[request.PlayerId].Item1.Wait();
else if (request.TeamId == 1)
semaDict1[request.PlayerId].Item1.Wait();
if (ship == null || ship.IsRemoved == true)
{ }
else
//if (ship != null && ship.IsRemoved != true)
//{
try
{
try
if (currentGameInfo != null && !exitFlag)
{
if (currentGameInfo != null && !exitFlag)
{
await responseStream.WriteAsync(currentGameInfo);
Console.WriteLine("Send!");
}
}
catch
{
if (!exitFlag)
{
Console.WriteLine($"The client {request.PlayerId} exited");
exitFlag = true;
}
await responseStream.WriteAsync(currentGameInfo);
Console.WriteLine("Send!");
}
finally
}
catch
{
if (!exitFlag)
{
if (request.TeamId == 0)
semaDict0[request.PlayerId].Item2.Release();
else if (request.TeamId == 1)
semaDict1[request.PlayerId].Item2.Release();
Console.WriteLine($"The client {request.PlayerId} exited");
exitFlag = true;
}
}
finally
{
if (request.TeamId == 0)
semaDict0[request.PlayerId].Item2.Release();
else if (request.TeamId == 1)
semaDict1[request.PlayerId].Item2.Release();
}
//}
} while (game.GameMap.Timer.IsGaming);
}

Expand Down

0 comments on commit e1c6c12

Please sign in to comment.