Skip to content

Commit 04c8fae

Browse files
committed
compliance
1 parent a162a2b commit 04c8fae

4 files changed

Lines changed: 23 additions & 16 deletions

File tree

Turbo.PacketHandlers/Users/RespectUserMessageHandler.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using Orleans;
44
using Turbo.Messages.Registry;
55
using Turbo.Primitives.Messages.Incoming.Users;
6-
using Turbo.Primitives.Messages.Outgoing.Users;
76
using Turbo.Primitives.Orleans;
87
using Turbo.Primitives.Rooms.Enums;
98

@@ -34,27 +33,14 @@ CancellationToken ct
3433
if (!consumed)
3534
return;
3635

37-
// Give respect to the target player
36+
// Give respect to the target player (grain sends room notification)
3837
var targetGrain = _grainFactory.GetPlayerGrain(message.UserId);
39-
var newTotal = await targetGrain
40-
.ReceiveRespectAsync(ctx.PlayerId, ct)
41-
.ConfigureAwait(false);
38+
await targetGrain.ReceiveRespectAsync(ctx.PlayerId, ct).ConfigureAwait(false);
4239

4340
// Play the thumbs-up expression on the giver
4441
var roomGrain = _grainFactory.GetRoomGrain(ctx.RoomId);
4542
await roomGrain
4643
.SetAvatarExpressionAsync(ctx.AsActionContext(), AvatarExpressionType.Respect, ct)
4744
.ConfigureAwait(false);
48-
49-
// Broadcast the respect notification to the entire room
50-
await roomGrain
51-
.SendComposerToRoomAsync(
52-
new RespectNotificationMessageComposer
53-
{
54-
UserId = message.UserId,
55-
RespectTotal = newTotal,
56-
}
57-
)
58-
.ConfigureAwait(false);
5945
}
6046
}

Turbo.Players/Grains/PlayerGrain.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Turbo.Logging;
1010
using Turbo.Primitives;
1111
using Turbo.Primitives.Grains.Players;
12+
using Turbo.Primitives.Messages.Outgoing.Users;
1213
using Turbo.Primitives.Orleans;
1314
using Turbo.Primitives.Orleans.Snapshots.Players;
1415
using Turbo.Primitives.Players;
@@ -185,6 +186,15 @@ public async Task<int> ReceiveRespectAsync(PlayerId giverId, CancellationToken c
185186
_state.RespectTotal++;
186187
await WriteToDatabaseAsync(ct);
187188

189+
var presence = _grainFactory.GetPlayerPresenceGrain((int)this.GetPrimaryKeyLong());
190+
await presence.SendComposerToActiveRoomAsync(
191+
new RespectNotificationMessageComposer
192+
{
193+
UserId = (int)_state.PlayerId,
194+
RespectTotal = _state.RespectTotal,
195+
}
196+
);
197+
188198
return _state.RespectTotal;
189199
}
190200

Turbo.Players/Grains/PlayerPresenceGrain.Room.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,13 @@ public Task SetPendingRoomAsync(RoomId roomId, bool approved)
115115

116116
return Task.CompletedTask;
117117
}
118+
119+
public async Task SendComposerToActiveRoomAsync(IComposer composer)
120+
{
121+
if (_state.ActiveRoomId <= 0)
122+
return;
123+
124+
var roomGrain = _grainFactory.GetRoomGrain(_state.ActiveRoomId);
125+
await roomGrain.SendComposerToRoomAsync(composer);
126+
}
118127
}

Turbo.Primitives/Players/Grains/IPlayerPresenceGrain.Room.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Threading;
22
using System.Threading.Tasks;
3+
using Turbo.Primitives.Networking;
34
using Turbo.Primitives.Orleans.Snapshots.Room;
45
using Turbo.Primitives.Rooms;
56

@@ -12,4 +13,5 @@ public partial interface IPlayerPresenceGrain
1213
public Task SetActiveRoomAsync(RoomId roomId, CancellationToken ct);
1314
public Task ClearActiveRoomAsync(CancellationToken ct);
1415
public Task SetPendingRoomAsync(RoomId roomId, bool approved);
16+
public Task SendComposerToActiveRoomAsync(IComposer composer);
1517
}

0 commit comments

Comments
 (0)