From 105215912b953560e6fa5f932ee2af22634bece7 Mon Sep 17 00:00:00 2001 From: ParticleG Date: Mon, 12 Aug 2024 12:59:14 +0800 Subject: [PATCH] - Register settings_changed message - Add TODO --- BotrisBattle.NET/BotrisBot.cs | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/BotrisBattle.NET/BotrisBot.cs b/BotrisBattle.NET/BotrisBot.cs index 812ecf0..a585833 100644 --- a/BotrisBattle.NET/BotrisBot.cs +++ b/BotrisBattle.NET/BotrisBot.cs @@ -27,8 +27,14 @@ public BotrisBot(string token) { _websocket = new BotrisWebsocket(token); + _websocket.On("authenticated", (payload) => + { + //Console.WriteLine("认证成功:{0}", payload.SessionId); + }); + _websocket.On("room_data", payload => { + // TODO: Consider network latency UpdateConfig?.Invoke( new UpdateConfigPayload { @@ -37,10 +43,7 @@ public BotrisBot(string token) ); }); - _websocket.On("authenticated", (payload) => - { - //Console.WriteLine("认证成功:{0}", payload.SessionId); - }); + _websocket.On("game_reset", () => { GameReset?.Invoke(); }); _websocket.On("game_started", () => { GameStart?.Invoke(); }); @@ -50,7 +53,16 @@ public BotrisBot(string token) RequestMove?.Invoke(payload); }); - _websocket.On("game_reset", () => { GameReset?.Invoke(); }); + _websocket.On("settings_changed", payload => + { + // TODO: Consider network latency + UpdateConfig?.Invoke( + new UpdateConfigPayload + { + Duration = (int)Math.Floor(1000 / payload.roomData.pps) + } + ); + }); }