feat: 远程控制协议增加“轮询间隔”参数

fix #12904
This commit is contained in:
uye
2025-06-06 13:44:53 +08:00
parent 964c64576d
commit e1b58dd884
9 changed files with 48 additions and 10 deletions

View File

@@ -258,6 +258,7 @@ namespace MaaWpfGui.Constants
public const string RemoteControlReportStatusUri = "RemoteControl.RemoteControlReportStatusUri";
public const string RemoteControlUserIdentity = "RemoteControl.RemoteControlUserIdentity";
public const string RemoteControlDeviceIdentity = "RemoteControl.RemoteControlDeviceIdentity";
public const string RemoteControlPollIntervalMs = "RemoteControl.RemoteControlPollIntervalMs";
public const string ExternalNotificationEnabled = "ExternalNotification.Enabled";
public const string ExternalNotificationSendWhenComplete = "ExternalNotification.SendWhenComplete";

View File

@@ -1005,6 +1005,7 @@ Please switch to the stage selection page before starting</system:String>
<system:String x:Key="RemoteControlUserIdentityLabel">User Identifier</system:String>
<system:String x:Key="RemoteControlGetTaskEndpointLabel">Get Task Endpoint</system:String>
<system:String x:Key="RemoteControlReportStatusEndpointLabel">Report Task Endpoint</system:String>
<system:String x:Key="RemoteControlPollIntervalMsLabel">Polling Interval (ms)</system:String>
<system:String x:Key="RemoteControlConnectionTestSuccess">Connection Test Successful!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">Connection Test Failed, reason: {0}.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">Connection Test Failed, Endpoint is empty.</system:String>

View File

@@ -1009,6 +1009,7 @@ C:\\leidian\\LDPlayer9
<system:String x:Key="RemoteControlUserIdentityLabel">ユーザー識別子</system:String>
<system:String x:Key="RemoteControlGetTaskEndpointLabel">タスクエンドポイントの取得</system:String>
<system:String x:Key="RemoteControlReportStatusEndpointLabel">タスクステータスの報告エンドポイント</system:String>
<system:String x:Key="RemoteControlPollIntervalMsLabel">ポーリング間隔 (ms)</system:String>
<system:String x:Key="RemoteControlConnectionTestSuccess">接続テスト成功!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">接続テスト失敗、理由: {0}。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">接続テスト失敗、エンドポイントが空です。</system:String>

View File

@@ -1008,6 +1008,7 @@ C:\\leidian\\LDPlayer9
<system:String x:Key="RemoteControlUserIdentityLabel">사용자 식별자</system:String>
<system:String x:Key="RemoteControlGetTaskEndpointLabel">작업 엔드포인트 가져오기</system:String>
<system:String x:Key="RemoteControlReportStatusEndpointLabel">작업 상태 보고 엔드포인트</system:String>
<system:String x:Key="RemoteControlPollIntervalMsLabel">폴링 간격 (ms)</system:String>
<system:String x:Key="RemoteControlConnectionTestSuccess">연결 테스트 성공!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">연결 테스트 실패, 원인: {0}.</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">연결 테스트 실패, 엔드포인트가 비어 있습니다.</system:String>

View File

@@ -1009,6 +1009,7 @@ C:\\leidian\\LDPlayer9。\n
<system:String x:Key="RemoteControlUserIdentityLabel">用户标识符</system:String>
<system:String x:Key="RemoteControlGetTaskEndpointLabel">获取任务端点</system:String>
<system:String x:Key="RemoteControlReportStatusEndpointLabel">汇报任务端点</system:String>
<system:String x:Key="RemoteControlPollIntervalMsLabel">轮询间隔 (ms)</system:String>
<system:String x:Key="RemoteControlConnectionTestSuccess">连接测试成功!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">连接测试失败,原因: {0}。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">连接测试失败,连接端点为空。</system:String>

View File

@@ -1007,6 +1007,7 @@ C:\\leidian\\LDPlayer9。\n
<system:String x:Key="RemoteControlUserIdentityLabel">使用者標識符</system:String>
<system:String x:Key="RemoteControlGetTaskEndpointLabel">獲取任務端點</system:String>
<system:String x:Key="RemoteControlReportStatusEndpointLabel">匯報任務端點</system:String>
<system:String x:Key="RemoteControlPollIntervalMsLabel">輪詢間隔 (ms)</system:String>
<system:String x:Key="RemoteControlConnectionTestSuccess">連接測試成功!</system:String>
<system:String x:Key="RemoteControlConnectionTestFail">連接測試失敗,原因: {0}。</system:String>
<system:String x:Key="RemoteControlConnectionTestFailEmpty">連接測試失敗,連接端點為空。</system:String>

View File

@@ -80,7 +80,7 @@ namespace MaaWpfGui.Services.RemoteControl
{
while (true)
{
await Task.Delay(1000);
await Task.Delay(RemoteSettings.RemoteControlPollIntervalMs);
try
{
if (!IsEndpointValid(RemoteSettings.RemoteControlGetTaskEndpointUri))
@@ -105,7 +105,7 @@ namespace MaaWpfGui.Services.RemoteControl
{
while (true)
{
await Task.Delay(1000);
await Task.Delay(RemoteSettings.RemoteControlPollIntervalMs);
try
{
if (!IsEndpointValid(RemoteSettings.RemoteControlGetTaskEndpointUri))
@@ -129,7 +129,7 @@ namespace MaaWpfGui.Services.RemoteControl
{
while (true)
{
await Task.Delay(1000);
await Task.Delay(RemoteSettings.RemoteControlPollIntervalMs);
try
{
if (!IsEndpointValid(RemoteSettings.RemoteControlGetTaskEndpointUri))

View File

@@ -12,6 +12,7 @@
// </copyright>
#nullable enable
using System;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using Stylet;
@@ -86,4 +87,20 @@ public class RemoteControlUserControlModel : PropertyChangedBase
ConfigurationHelper.SetValue(ConfigurationKeys.RemoteControlDeviceIdentity, value);
}
}
private int _remoteControlPollIntervalMs = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.RemoteControlPollIntervalMs, "1000"));
public int RemoteControlPollIntervalMs
{
get => _remoteControlPollIntervalMs;
set
{
if (!SetAndNotify(ref _remoteControlPollIntervalMs, value))
{
return;
}
ConfigurationHelper.SetValue(ConfigurationKeys.RemoteControlPollIntervalMs, value.ToString());
}
}
}

View File

@@ -24,6 +24,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@@ -69,21 +70,35 @@
Margin="0,5,0,5"
Text="{Binding RemoteControlReportStatusUri}" />
<!-- User Identity Input -->
<controls:TextBlock
Grid.Row="3"
Grid.Column="0"
Margin="10"
Block.TextAlignment="Center"
Text="{DynamicResource RemoteControlPollIntervalMsLabel}"
TextWrapping="Wrap" />
<TextBox
Grid.Row="3"
Grid.Column="1"
Grid.ColumnSpan="2"
Margin="0,5,0,5"
Text="{Binding RemoteControlPollIntervalMs, UpdateSourceTrigger=PropertyChanged}" />
<!-- User Identity Input -->
<controls:TextBlock
Grid.Row="4"
Grid.Column="0"
Margin="10"
Block.TextAlignment="Center"
Text="{DynamicResource RemoteControlUserIdentityLabel}"
TextWrapping="Wrap" />
<TextBox
Grid.Row="3"
Grid.Row="4"
Grid.Column="1"
Margin="0,5,0,5"
Text="{Binding RemoteControlUserIdentity}" />
<Button
Grid.Row="3"
Grid.Row="4"
Grid.Column="2"
Margin="5"
Command="{s:Action ConnectionTest,
@@ -92,21 +107,21 @@
<!-- Remote ID (Read-only & Copyable) -->
<controls:TextBlock
Grid.Row="4"
Grid.Row="5"
Grid.Column="0"
Margin="10"
Block.TextAlignment="Center"
Text="{DynamicResource RemoteControlDeviceIdentityLabel}"
TextWrapping="Wrap" />
<TextBox
Grid.Row="4"
Grid.Row="5"
Grid.Column="1"
Margin="0,5,0,5"
ContextMenuService.IsEnabled="False"
IsReadOnly="True"
Text="{Binding RemoteControlDeviceIdentity}" />
<Button
Grid.Row="4"
Grid.Row="5"
Grid.Column="2"
Margin="5"
Command="{s:Action RegenerateDeviceIdentity,
@@ -114,7 +129,7 @@
Content="{DynamicResource RemoteControlRegenerateDeviceIdentity}" />
<StackPanel
Grid.Row="5"
Grid.Row="6"
Grid.Column="0"
Grid.ColumnSpan="3"
HorizontalAlignment="Center">