Browse Source

Merge branch 'master' of http://git.jetplasma-oa.com/Jet/ApolloNewWorld

Zixuan 1 week ago
parent
commit
cf6da53911

+ 0 - 4
FurnaceNewWorld/Communication/Communicator/Communicator.csproj

@@ -10,8 +10,4 @@
     <PackageReference Include="Microsoft.AspNet.SignalR.Client" />
   </ItemGroup>
 
-  <ItemGroup>
-    <ProjectReference Include="..\..\Universal\Universal.csproj" />
-  </ItemGroup>
-
 </Project>

+ 3 - 1
FurnaceNewWorld/Communication/Communicator/ICommunicator.cs

@@ -7,5 +7,7 @@ public interface ICommunicator : IDisposable
 
 public interface ICommunicatorProvider
 {
-    void DataChangedNotify(string dataKey, object rawData);
+    void NotifyDataChanged(string dataKey, object rawData);
+
+    void NotifyAllDataReceived(Dictionary<string, object> dataItems);
 }

+ 6 - 1
FurnaceNewWorld/Communication/Communicator/MockCommunicatorProvider.cs

@@ -8,7 +8,12 @@ namespace Communicator
 {
     public class MockCommunicatorProvider : ICommunicatorProvider
     {
-        void ICommunicatorProvider.DataChangedNotify(string dataKey, object rawData)
+        public void NotifyAllDataReceived(Dictionary<string, object> dataItems)
+        {
+            //TODO:
+        }
+
+        public void NotifyDataChanged(string dataKey, object rawData)
         {
             //TODO:
         }

+ 13 - 1
FurnaceNewWorld/Communication/Communicator/UISignalRClient.cs

@@ -47,6 +47,7 @@ namespace Communicator
                 _hubConnection.StateChanged += OnStateChanged;
 
                 _hubProxy = _hubConnection.CreateHubProxy(_hubName);
+                _hubProxy.On<Dictionary<string, object>>(nameof(ReceiveAllDataItems), ReceiveAllDataItems);
                 _hubProxy.On<Dictionary<string, object>>(nameof(ReceiveChangedDataItems), ReceiveChangedDataItems);
                 _hubConnection.Start().Wait();
 
@@ -58,6 +59,17 @@ namespace Communicator
             }
         }
 
+
+
+        private void ReceiveAllDataItems(Dictionary<string, object> dataItems)
+        {
+            if (dataItems.Count <= 0)
+            {
+                return;
+            }
+            _provider?.NotifyAllDataReceived(dataItems);
+        }
+
         private void ReceiveChangedDataItems(Dictionary<string, object> dataItems)
         {
             if (dataItems.Count <= 0)
@@ -76,7 +88,7 @@ namespace Communicator
             while (await _changedDataItems.OutputAvailableAsync() && !_cancellationTokenSource.IsCancellationRequested)
             {
                 var item = await _changedDataItems.ReceiveAsync();
-                _provider?.DataChangedNotify(item.Key, item.Value);
+                _provider?.NotifyDataChanged(item.Key, item.Value);
             }
         }