aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/ExternalBridge
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-23 23:50:13 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-23 23:50:13 +0200
commit879a7c2179d991f4b68a513f60de3472b2e64102 (patch)
tree283332c93e59ff85e05a61c930760ec3b1b2525b /Software/Visual_Studio/Tango.Integration/ExternalBridge
parentd4cde3ccf2c29991b65285396fb97eafa1e434df (diff)
downloadTango-879a7c2179d991f4b68a513f60de3472b2e64102.tar.gz
Tango-879a7c2179d991f4b68a513f60de3472b2e64102.zip
Implemented cached entities using DataResolver<T>.
Implemented DataResolver Builder. Implemented offline gateway, authentication, machines... Implemented online checking. Moved FSEWebClient and Gateway to BL. Implemented blocking of machines outside of the organization.
Diffstat (limited to 'Software/Visual_Studio/Tango.Integration/ExternalBridge')
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs35
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs14
-rw-r--r--Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs14
3 files changed, 61 insertions, 2 deletions
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs
index da85ad531..ce0a6ad43 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs
@@ -13,6 +13,7 @@ using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
+using Tango.BL.Entities;
using Tango.Core;
using Tango.Core.Helpers;
using Tango.Integration.ExternalBridge.Web;
@@ -58,6 +59,11 @@ namespace Tango.Integration.ExternalBridge
/// </summary>
public ExternalBridgeSignalRConfiguration SignalRConfiguration { get; set; }
+ /// <summary>
+ /// Gets or sets the known machines.
+ /// </summary>
+ public List<Machine> KnownMachines { get; set; }
+
private bool _isStarted;
/// <summary>
/// Gets or sets a value indicating whether this instance is started.
@@ -78,6 +84,11 @@ namespace Tango.Integration.ExternalBridge
SignalRConfiguration = new ExternalBridgeSignalRConfiguration();
}
+ public ExternalBridgeScanner(List<Machine> knownMachines) : this()
+ {
+ KnownMachines = knownMachines;
+ }
+
/// <summary>
/// Start scanning. (Results will be available through <see cref="AvailableMachines"/>).
/// </summary>
@@ -228,7 +239,17 @@ namespace Tango.Integration.ExternalBridge
if (!AvailableMachines.OfType<ExternalBridgeTcpClient>().ToList().Exists(x => x.SerialNumber == packet.SerialNumber && x.IPAddress == address))
{
- ExternalBridgeTcpClient newMachine = new ExternalBridgeTcpClient(packet.SerialNumber, address);
+ ExternalBridgeTcpClient newMachine = null;
+ var knownMachine = KnownMachines.FirstOrDefault(x => x.SerialNumber == packet.SerialNumber);
+
+ if (knownMachine == null)
+ {
+ newMachine = new ExternalBridgeTcpClient(packet.SerialNumber, address);
+ }
+ else
+ {
+ newMachine = new ExternalBridgeTcpClient(knownMachine, address);
+ }
LogManager.Log("Found a new machine via TCP " + newMachine.SerialNumber);
@@ -271,7 +292,17 @@ namespace Tango.Integration.ExternalBridge
foreach (var machine in machines.Where(x => !AvailableMachines.OfType<ExternalBridgeSignalRClient>().ToList().Exists(y => y.SerialNumber == x.SerialNumber)))
{
- ExternalBridgeSignalRClient newMachine = new ExternalBridgeSignalRClient(SignalRConfiguration.Address, SignalRConfiguration.Hub, machine.SerialNumber);
+ ExternalBridgeSignalRClient newMachine = null;
+ var knownMachine = KnownMachines.FirstOrDefault(x => x.SerialNumber == machine.SerialNumber);
+
+ if (knownMachine == null)
+ {
+ newMachine = new ExternalBridgeSignalRClient(SignalRConfiguration.Address, SignalRConfiguration.Hub, machine.SerialNumber);
+ }
+ else
+ {
+ newMachine = new ExternalBridgeSignalRClient(SignalRConfiguration.Address, SignalRConfiguration.Hub, knownMachine);
+ }
ThreadsHelper.InvokeUINow(() =>
{
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs
index dc1bd1203..1596d2c9b 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs
@@ -30,6 +30,20 @@ namespace Tango.Integration.ExternalBridge
UseKeepAlive = false;
}
+ public ExternalBridgeSignalRClient(String url, String hub, Machine machine)
+ {
+ ComponentName = $"External Bridge SignalR Client {_component_counter++}";
+
+ SerialNumber = machine.SerialNumber;
+ IPAddress = hub;
+ Machine = machine;
+ Adapter = new SignalRTransportAdapter(url, hub, SignalRTransportAdapterMode.CreateSession, SerialNumber);
+
+ KeepAliveTimeout = TimeSpan.FromSeconds(5);
+ KeepAliveRetries = 2;
+ UseKeepAlive = false;
+ }
+
public override async Task Connect(ExternalBridgeLoginRequest login)
{
if (State != TransportComponentState.Connected)
diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
index fbfa6b0ca..9ba2166eb 100644
--- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
+++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs
@@ -280,6 +280,20 @@ namespace Tango.Integration.ExternalBridge
Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.GetOrCreate<IntegrationSettings>().ExternalBridgeServicePort);
}
+ public ExternalBridgeTcpClient(Machine machine, String ipAddress)
+ {
+ ComponentName = $"External Bridge TCP Client {_component_counter++}";
+ Machine = machine;
+ SerialNumber = Machine.SerialNumber;
+ IPAddress = ipAddress;
+ KeepAliveTimeout = TimeSpan.FromSeconds(5);
+ KeepAliveRetries = 2;
+ UseKeepAlive = false;
+ EnableDiagnostics = true;
+
+ Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.GetOrCreate<IntegrationSettings>().ExternalBridgeServicePort);
+ }
+
/// <summary>
/// Returns a <see cref="System.String" /> that represents this instance.
/// </summary>