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) + } + ); + }); }