Issue #262: function GetQuotes load data from MT instead of using cached quotes

This commit is contained in:
Viacheslav Demydiuk
2025-12-05 23:43:27 +02:00
parent 0c874773e5
commit 249b0f9fbb
8 changed files with 88 additions and 60 deletions
+7 -7
View File
@@ -8,12 +8,12 @@
ExpertList = 3,
ExpertAdded = 4,
ExpertRemoved = 5,
Notification = 6
ServiceRequest = 6
}
internal enum MtNotificationType
internal enum ServiceRequestType
{
ClientReady = 0
ExpertList = 0
}
internal abstract class MtMessage
@@ -43,16 +43,16 @@
}
}
internal class MtNotification(MtNotificationType notificationType) : MtMessage
internal class MtServiceRequest(ServiceRequestType requestType) : MtMessage
{
public override MessageType MsgType => MessageType.Notification;
public override MessageType MsgType => MessageType.ServiceRequest;
protected override string GetMessageBody()
{
return $"{(int)NotificationType}";
return $"{(int)ServiceRequestType}";
}
public MtNotificationType NotificationType { private set; get; } = notificationType;
public ServiceRequestType ServiceRequestType { private set; get; } = requestType;
}
internal class MtEvent(int expertHandle, int eventType, string payload) : MtMessage
+11 -11
View File
@@ -89,19 +89,19 @@ namespace MtClient
public HashSet<int>? RequestExpertsList()
{
CommandTask<object> notificationTask = new();
lock (notification_tasks_)
CommandTask<object> requestTask = new();
lock (service_requests_)
{
notification_tasks_[MtNotificationType.ClientReady] = notificationTask;
service_requests_[ServiceRequestType.ExpertList] = requestTask;
}
MtNotification notification = new(MtNotificationType.ClientReady);
Send(notification);
MtServiceRequest request = new(ServiceRequestType.ExpertList);
Send(request);
var response = notificationTask.WaitResponse(10000); // 10 sec
lock (notification_tasks_)
var response = requestTask.WaitResponse(10000); // 10 sec
lock (service_requests_)
{
notification_tasks_.Remove(MtNotificationType.ClientReady);
service_requests_.Remove(ServiceRequestType.ExpertList);
}
return response as HashSet<int>;
@@ -277,9 +277,9 @@ namespace MtClient
{
logger_.Debug($"MtRpcClient.ProcessExpertList: experts count - {experts.Count}");
lock (notification_tasks_)
lock (service_requests_)
{
if (notification_tasks_.TryGetValue(MtNotificationType.ClientReady, out CommandTask<object>? value))
if (service_requests_.TryGetValue(ServiceRequestType.ExpertList, out CommandTask<object>? value))
value.SetResponse(experts);
}
}
@@ -301,7 +301,7 @@ namespace MtClient
private int nextCommandId = 0;
private readonly Dictionary<int, CommandTask<string>> tasks_ = [];
private readonly Dictionary<MtNotificationType, CommandTask<object>> notification_tasks_ = [];
private readonly Dictionary<ServiceRequestType, CommandTask<object>> service_requests_ = [];
private readonly IRpcLogger logger_;
}