Skip to content

Commit

Permalink
- Register settings_changed message
Browse files Browse the repository at this point in the history
- Add TODO
  • Loading branch information
ParticleG committed Aug 12, 2024
1 parent 2f89bb0 commit 1052159
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions BotrisBattle.NET/BotrisBot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,14 @@ public BotrisBot(string token)
{
_websocket = new BotrisWebsocket(token);

_websocket.On<AuthenticatedPayload>("authenticated", (payload) =>
{
//Console.WriteLine("认证成功:{0}", payload.SessionId);
});

_websocket.On<RoomDataPayload>("room_data", payload =>
{
// TODO: Consider network latency
UpdateConfig?.Invoke(
new UpdateConfigPayload
{
Expand All @@ -37,10 +43,7 @@ public BotrisBot(string token)
);
});

_websocket.On<AuthenticatedPayload>("authenticated", (payload) =>
{
//Console.WriteLine("认证成功:{0}", payload.SessionId);
});
_websocket.On("game_reset", () => { GameReset?.Invoke(); });

_websocket.On("game_started", () => { GameStart?.Invoke(); });

Expand All @@ -50,7 +53,16 @@ public BotrisBot(string token)
RequestMove?.Invoke(payload);
});

_websocket.On("game_reset", () => { GameReset?.Invoke(); });
_websocket.On<RoomDataPayload>("settings_changed", payload =>
{
// TODO: Consider network latency
UpdateConfig?.Invoke(
new UpdateConfigPayload
{
Duration = (int)Math.Floor(1000 / payload.roomData.pps)
}
);
});
}


Expand Down

0 comments on commit 1052159

Please sign in to comment.