This commit is contained in:
2023-01-29 16:53:26 -06:00
parent 8a25c0ed35
commit e2eff4f8b5
5 changed files with 35 additions and 15 deletions

View File

@@ -13,7 +13,7 @@
}
else if (isSpectating)
{
<SpectatorGameBoard Session="session" OnRefetchSession="RefetchSession" />
<SpectatorGameBoard Session="session" />
}
else
{
@@ -32,16 +32,25 @@ else
protected override void OnInitialized()
{
base.OnInitialized();
ShogiSocket.OnPlayerMoved += OnPlayerMoved_RefetchSession;
ShogiSocket.OnSessionJoined +=
ShogiSocket.OnPlayerMoved += OnPlayerMoved_FetchSession;
ShogiSocket.OnSessionJoined += OnSessionJoined_FetchSession;
}
protected override async Task OnParametersSetAsync()
{
await RefetchSession();
await FetchSession();
}
async Task RefetchSession()
Task OnSessionJoined_FetchSession(SessionJoinedByPlayerSocketMessage args)
{
if (args.SessionName == SessionName)
{
return FetchSession();
}
return Task.CompletedTask;
}
async Task FetchSession()
{
if (!string.IsNullOrWhiteSpace(SessionName))
{
@@ -59,11 +68,11 @@ else
}
}
Task OnPlayerMoved_RefetchSession(PlayerHasMovedMessage args)
Task OnPlayerMoved_FetchSession(PlayerHasMovedMessage args)
{
if (args.SessionName == SessionName)
{
return RefetchSession();
return FetchSession();
}
return Task.CompletedTask;
}