diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-22 05:15:57 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-22 05:15:57 +0300 |
| commit | a9b1c4cb5c4d945565e72e80ac0f938a49da3e5f (patch) | |
| tree | 739307651882bce538653dc76c58c546b2d87699 /Software | |
| parent | 7bd70fcb311c808b65b62e774755dcbd6b0d63cd (diff) | |
| download | Tango-a9b1c4cb5c4d945565e72e80ac0f938a49da3e5f.tar.gz Tango-a9b1c4cb5c4d945565e72e80ac0f938a49da3e5f.zip | |
Implemented pre-connection protocol configuration.
Improved error handling across transport layer.
Improved unexpected app crash for PPC.
Improved transporter request received handlers tunneling.
Diffstat (limited to 'Software')
49 files changed, 999 insertions, 369 deletions
diff --git a/Software/PMR/Messages/Common/MessageType.proto b/Software/PMR/Messages/Common/MessageType.proto index e9146cc5f..4f2147b02 100644 --- a/Software/PMR/Messages/Common/MessageType.proto +++ b/Software/PMR/Messages/Common/MessageType.proto @@ -146,6 +146,8 @@ enum MessageType UpdateStatusResponse = 1016; GenericRequest = 1017; GenericResponse = 1018; + ConfigureProtocolRequest = 1019; + ConfigureProtocolResponse = 1020; diff --git a/Software/PMR/Messages/Integration/ConfigureProtocolRequest.proto b/Software/PMR/Messages/Integration/ConfigureProtocolRequest.proto new file mode 100644 index 000000000..850df63de --- /dev/null +++ b/Software/PMR/Messages/Integration/ConfigureProtocolRequest.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; + +import "GenericMessageProtocol.proto"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message ConfigureProtocolRequest +{ + bool EnableCompression = 1; + GenericMessageProtocol GenericProtocol = 2; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Integration/ConfigureProtocolResponse.proto b/Software/PMR/Messages/Integration/ConfigureProtocolResponse.proto new file mode 100644 index 000000000..1f32296da --- /dev/null +++ b/Software/PMR/Messages/Integration/ConfigureProtocolResponse.proto @@ -0,0 +1,9 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +message ConfigureProtocolResponse +{ + bool Confirmed = 1; +}
\ No newline at end of file diff --git a/Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto b/Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto index 4a7d5b59b..d797e6de3 100644 --- a/Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto +++ b/Software/PMR/Messages/Integration/ExternalBridgeUdpDiscoveryPacket.proto @@ -7,5 +7,4 @@ message ExternalBridgeUdpDiscoveryPacket { string Time = 1; string SerialNumber = 2; - bool CompressionEnabled = 3; }
\ No newline at end of file diff --git a/Software/PMR/Messages/Integration/GenericMessageProtocol.proto b/Software/PMR/Messages/Integration/GenericMessageProtocol.proto new file mode 100644 index 000000000..cb6021944 --- /dev/null +++ b/Software/PMR/Messages/Integration/GenericMessageProtocol.proto @@ -0,0 +1,11 @@ +syntax = "proto3"; + +package Tango.PMR.Integration; +option java_package = "com.twine.tango.pmr.integration"; + +enum GenericMessageProtocol +{ + Json = 0; + Bson = 1; + Protobuf = 2; +}
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml index 922790d5e..83481a9d7 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Converters.xaml @@ -45,4 +45,5 @@ <localConverters:JobProgressToPositionConverter x:Key="JobProgressToPositionConverter" /> <localConverters:FilePathToIconConverter x:Key="FilePathToIconConverter" /> <converters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter" /> + <converters:GenericMessageProtocolToStringConverter x:Key="GenericMessageProtocolToStringConverter" /> </ResourceDictionary>
\ No newline at end of file diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs index 55866361b..f6bbaab87 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Connection/DefaultMachineProvider.cs @@ -24,6 +24,7 @@ using Tango.FSE.UI.Dialogs; using Tango.Integration.ExternalBridge; using Tango.Integration.Operation; using Tango.Logging; +using Tango.PMR.Integration; using Tango.SharedUI; using Tango.Transport; @@ -162,7 +163,7 @@ namespace Tango.FSE.UI.Connection { _machineEventsStateProvider = new FSEMachineEventsStateProvider(); - MachineOperator = new ExternalBridgeTcpClient("N/A", "N/A", false); + MachineOperator = new ExternalBridgeTcpClient("N/A", "N/A"); MachineOperator.MachineEventsStateProvider = _machineEventsStateProvider; MachineOperator.StateChanged += MachineOperator_StateChanged; MachineOperator.As<ExternalBridgeTcpClient>().SessionClosed += DefaultMachineProvider_SessionClosed; @@ -185,7 +186,7 @@ namespace Tango.FSE.UI.Connection { try { - LogManager.Log($"Connecting to machine '{machine.GetType().Name}' => '{machine.SerialNumber}' => '{machine.Adapter?.Address}' => {(machine.CompressionEnabled ? "Compression Enabled" : "Compression Disabled")}..."); + LogManager.Log($"Connecting to machine '{machine.GetType().Name}' => '{machine.SerialNumber}' => '{machine.Adapter?.Address}'..."); IsBusy = true; @@ -214,7 +215,7 @@ namespace Tango.FSE.UI.Connection vm = await NotificationProvider.ShowDialog(new MachineConnectionSignalRViewVM(secureClient)); } - secureClient.LoginRequest = new PMR.Integration.ExternalBridgeLoginRequest() + secureClient.LoginRequest = new ExternalBridgeLoginRequest() { AppID = "Tango FSE", HostName = Environment.MachineName, @@ -225,6 +226,12 @@ namespace Tango.FSE.UI.Connection UserName = AuthenticationProvider.CurrentUser.Contact.FullName }; + secureClient.ConfigureProtocolRequest = new ConfigureProtocolRequest() + { + EnableCompression = true, + GenericProtocol = GenericMessageProtocol.Bson + }; + LogManager.Log($"Target machine requires a secure connection. Login Request:\n{secureClient.LoginRequest.ToJsonString()}"); } else diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs index e7f9772ff..2e3ffec19 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs @@ -169,9 +169,10 @@ namespace Tango.FSE.UI.FileSystem _webRtcTransporter = new BasicTransporter(new WebRtcTransportAdapter(_machineProvider.MachineOperator, WebRtcTransportAdapterMode.Active, WEB_RTC_CHANNEL_NAME) { - EnableCompression = _machineProvider.MachineOperator.CompressionEnabled, + EnableCompression = _machineProvider.MachineOperator.Adapter.EnableCompression, }); _webRtcTransporter.UseKeepAlive = false; + _webRtcTransporter.GenericProtocol = _machineProvider.MachineOperator.GenericProtocol; _webRtcTransporter.ComponentName = "File System Active WebRTC Transporter"; await _webRtcTransporter.Connect(); diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Insights/DefaultInsightsProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.UI/Insights/DefaultInsightsProvider.cs index 1ddf0fa22..a4958f25d 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Insights/DefaultInsightsProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Insights/DefaultInsightsProvider.cs @@ -47,7 +47,7 @@ namespace Tango.FSE.UI.Insights { StartDateUTC = startDateUTC, EndDateUTC = endTimeUTC - }, new Transport.TransportRequestConfig() + }, new TransportRequestConfig() { Timeout = TimeSpan.FromMinutes(1), }); diff --git a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml index db2559a9d..c0c54b1b6 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/Panes/ConnectedMachinePane.xaml @@ -8,9 +8,11 @@ xmlns:emulations="clr-namespace:Tango.Emulations.ExternalBridge;assembly=Tango.Emulations" xmlns:controls="clr-namespace:Tango.SharedUI.Controls;assembly=Tango.SharedUI" xmlns:commonControls="clr-namespace:Tango.FSE.Common.Controls;assembly=Tango.FSE.Common" + xmlns:localConverters="clr-namespace:Tango.FSE.UI.Converters" xmlns:local="clr-namespace:Tango.FSE.UI.Panes" mc:Ignorable="d" d:DesignHeight="600" d:DesignWidth="350" d:DataContext="{d:DesignInstance Type=local:ConnectedMachinePaneVM, IsDesignTimeCreatable=False}"> + <Grid> <DockPanel> <Button Command="{Binding DisconnectCommand}" Style="{StaticResource FSE_Button_Red}" DockPanel.Dock="Bottom" Height="50" Margin="5" material:ButtonAssist.CornerRadius="25"> @@ -81,6 +83,8 @@ </TextBlock> <TextBlock FontWeight="SemiBold" Text="Compression:" /> <TextBlock Text="{Binding MachineProvider.MachineOperator.Adapter.EnableCompression,Mode=OneWay,Converter={StaticResource BooleanToYesNoConverter}}" /> + <TextBlock FontWeight="SemiBold" Text="Generic Protocol:" /> + <TextBlock Text="{Binding MachineProvider.MachineOperator.GenericProtocol,Mode=OneWay,Converter={StaticResource GenericMessageProtocolToStringConverter}}" /> <TextBlock FontWeight="SemiBold" Text="Diagnostics Frame Rate:" /> <TextBlock> <Run Text="{Binding DiagnosticsProvider.FrameRate,Mode=OneWay}"></Run> @@ -88,7 +92,7 @@ </TextBlock> </controls:TableGrid> </StackPanel> - + </StackPanel> </ScrollViewer> </Grid> diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml index 295d6b2dc..600104095 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/ConnectedMachineView.xaml @@ -19,6 +19,8 @@ <converters:BooleanToVisibilityInverseConverter x:Key="BooleanToVisibilityInverseConverter"></converters:BooleanToVisibilityInverseConverter> <converters:BooleanInverseConverter x:Key="BooleanInverseConverter"></converters:BooleanInverseConverter> <converters:ByteArrayToFileSizeConverter x:Key="ByteArrayToFileSizeConverter" /> + <converters:GenericMessageProtocolToStringConverter x:Key="GenericMessageProtocolToStringConverter" /> + <converters:BooleanToYesNoConverter x:Key="BooleanToYesNoConverter" /> </UserControl.Resources> <Grid> @@ -95,6 +97,10 @@ <Run Text="{Binding Adapter.TransferRate,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}"></Run> <Run Text="/ sec"></Run> </TextBlock> + <TextBlock FontWeight="SemiBold" Text="Compression:" /> + <TextBlock Text="{Binding Adapter.EnableCompression,Mode=OneWay,Converter={StaticResource BooleanToYesNoConverter}}" /> + <TextBlock FontWeight="SemiBold" Text="Generic Protocol:" /> + <TextBlock Text="{Binding GenericProtocol,Mode=OneWay,Converter={StaticResource GenericMessageProtocolToStringConverter}}" /> <TextBlock FontWeight="SemiBold" Text="Diagnostics Frame Rate:" /> <TextBlock> <Run Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.DiagnosticsFrameProvider.FrameRate,Mode=OneWay,IsAsync=True}"></Run> @@ -138,6 +144,10 @@ <Run Text="{Binding Adapter.TransferRate,Converter={StaticResource ByteArrayToFileSizeConverter},Mode=OneWay}"></Run> <Run Text="/ sec"></Run> </TextBlock> + <TextBlock FontWeight="SemiBold" Text="Compression:" /> + <TextBlock Text="{Binding Adapter.EnableCompression,Mode=OneWay,Converter={StaticResource BooleanToYesNoConverter}}" /> + <TextBlock FontWeight="SemiBold" Text="Generic Protocol:" /> + <TextBlock Text="{Binding GenericProtocol,Mode=OneWay,Converter={StaticResource GenericMessageProtocolToStringConverter}}" /> <TextBlock FontWeight="SemiBold" Text="Diagnostics Frame Rate:" /> <TextBlock> <Run Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl},Path=DataContext.DiagnosticsFrameProvider.FrameRate,Mode=OneWay,IsAsync=True}"></Run> diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml index 3e7162616..cb3d46e70 100644 --- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml +++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.MachineSettings/Views/MainView.xaml @@ -12,6 +12,7 @@ xmlns:connectivity="clr-namespace:Tango.PPC.Common.Connectivity;assembly=Tango.PPC.Common" xmlns:adapters="clr-namespace:Tango.Transport.Adapters;assembly=Tango.Transport" xmlns:global="clr-namespace:Tango.PPC.MachineSettings" + xmlns:integrationPMR="clr-namespace:Tango.PMR.Integration;assembly=Tango.PMR" xmlns:local="clr-namespace:Tango.PPC.MachineSettings.Views" mc:Ignorable="d" d:DesignHeight="4000" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:MainViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.MainViewVM}"> @@ -297,11 +298,6 @@ </DockPanel> <DockPanel Margin="0 20 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> - <TextBlock VerticalAlignment="Center">External Bridge Transport Compression</TextBlock> - <touch:TouchToggleSlider IsChecked="{Binding Settings.EnableExternalBridgeTransportCompression}" Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90"></touch:TouchToggleSlider> - </DockPanel> - - <DockPanel Margin="0 20 0 0" TextElement.FontSize="{StaticResource TangoDefaultFontSize}"> <TextBlock VerticalAlignment="Center">Enable External Bridge SignalR</TextBlock> <touch:TouchToggleSlider IsChecked="{Binding Settings.EnableExternalBridgeSignalR}" Margin="0 0 100 0" DockPanel.Dock="Right" Style="{StaticResource TangoToggleButtonGrayAccent}" HorizontalAlignment="Right" Width="90"></touch:TouchToggleSlider> </DockPanel> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/ExternalBridge/PPCExternalBridgeService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/ExternalBridge/PPCExternalBridgeService.cs index 236c066e3..99951d812 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/ExternalBridge/PPCExternalBridgeService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/ExternalBridge/PPCExternalBridgeService.cs @@ -53,7 +53,7 @@ namespace Tango.PPC.Common.ExternalBridge applicationManager.ApplicationReady += (_, __) => { var settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); - EnableTransportCompression = settings.EnableExternalBridgeTransportCompression; + //TODO: Configure external bridge for configure protocol enforce... MachineOperator = machineProvider.MachineOperator; Machine = machineProvider.Machine; SignalRConfiguration.Enabled = settings.EnableExternalBridgeSignalR; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs index 958c1aa12..8272ea34d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/FileSystem/DefaultFileSystemService.cs @@ -34,7 +34,7 @@ namespace Tango.PPC.Common.FileSystem private FileSystemManager _manager; private Dictionary<String, FileSystemOperation> _operations; private Dictionary<ExternalBridgeReceiver, BasicTransporter> _webRtcClients; - private bool _enableCompression; + private PPCSettings _settings; public bool Enabled { get; set; } = true; public bool EnableWebRTC { get; set; } = true; @@ -45,7 +45,7 @@ namespace Tango.PPC.Common.FileSystem _manager = new FileSystemManager(); _operations = new Dictionary<string, FileSystemOperation>(); externalBridge.RegisterRequestHandler(this); - _enableCompression = SettingsManager.Default.GetOrCreate<PPCSettings>().EnableExternalBridgeTransportCompression; + _settings = SettingsManager.Default.GetOrCreate<PPCSettings>(); } [ExternalBridgeRequestHandlerMethod(typeof(InitWebRtcRequest), RequestHandlerLoggingMode.LogRequestNameAndContent)] @@ -71,7 +71,7 @@ namespace Tango.PPC.Common.FileSystem LogManager.Log("Initializing WebRTC transport adapter on 'Passive' mode."); var webRtcAdapter = new WebRtcTransportAdapter(receiver, WebRtcTransportAdapterMode.Passive, request.DataChannelName) { - EnableCompression = _enableCompression + EnableCompression = receiver.Adapter.EnableCompression }; webRtcAdapter.Ready += (x, e) => { @@ -79,7 +79,7 @@ namespace Tango.PPC.Common.FileSystem }; BasicTransporter webRtcTransporter = new BasicTransporter(webRtcAdapter); - webRtcTransporter = new BasicTransporter(webRtcAdapter); + webRtcTransporter.GenericProtocol = receiver.GenericProtocol; webRtcTransporter.ComponentName = "File System Passive WebRTC Transporter"; webRtcTransporter.UseKeepAlive = false; webRtcTransporter.RegisterRequestHandler<ChunkDownloadRequest>(WebRtcChunkDownloadRequestReceived); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs index bd21b3bb0..431e9dd07 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/PPCSettings.cs @@ -7,6 +7,7 @@ using System.Threading.Tasks; using Tango.BL.Enumerations; using Tango.Integration.Operation; using Tango.Logging; +using Tango.PMR.Integration; using Tango.PMR.Printing; using Tango.Settings; using Tango.Transport.Adapters; @@ -61,11 +62,6 @@ namespace Tango.PPC.Common public String ExternalBridgePassword { get; set; } /// <summary> - /// Gets or sets a value indicating whether to enable transport compression for external bridge clients. - /// </summary> - public bool EnableExternalBridgeTransportCompression { get; set; } - - /// <summary> /// Gets or sets a value indicating whether [enable hot spot]. /// </summary> public bool EnableHotSpot { get; set; } @@ -301,7 +297,6 @@ namespace Tango.PPC.Common EmbeddedComPort = "COM10"; EmbeddedDeviceHint = "Tango USB Serial Port"; ExternalBridgePassword = "Aa123456"; - EnableExternalBridgeTransportCompression = true; HotSpotPassword = "Aa123456"; LockScreenTimeout = TimeSpan.FromMinutes(10); LockScreenPassword = "1111"; diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index a55b50e5b..5272eb35d 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -8,7 +8,9 @@ <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6" /> </startup> <runtime> - <legacyCorruptedStateExceptionsPolicy enabled="true|false"/> + <legacyCorruptedStateExceptionsPolicy enabled="true" /> + <legacyUnhandledExceptionPolicy enabled="1" /> + <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <!--Required for cefCharp--> <probing privatePath="x86"/> diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs index 2b56561b5..16eb656a8 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.xaml.cs @@ -114,17 +114,17 @@ namespace Tango.PPC.UI /// <param name="e">The <see cref="ApplicationCrashedEventArgs"/> instance containing the event data.</param> private void ExceptionTrapper_ApplicationCrashed(object sender, ApplicationCrashedEventArgs e) { - e.TryRecover = true; - - if (e.Exception.ToString().Contains("FocusVisualStyle")) + List<String> ignoredExceptions = new List<string>() { - LogManager.Log("FocusVisualStyle Error occurred. Ignoring..."); - return; - } + "FocusVisualStyle", + "ThreadAbortException", + "A Task's exception(s) were not observed" + }; + + String exceptionString = e.Exception.ToStringSafe(); - if (e.Exception.ToString().Contains("A Task's exception(s) were not observed")) + if (ignoredExceptions.Exists(x => exceptionString.Contains(x))) { - LogManager.Log("Task not observed exception. Ignoring..."); return; } diff --git a/Software/Visual_Studio/Tango.Emulations/EmulatorBase.cs b/Software/Visual_Studio/Tango.Emulations/EmulatorBase.cs index 99532195e..ca40cce7a 100644 --- a/Software/Visual_Studio/Tango.Emulations/EmulatorBase.cs +++ b/Software/Visual_Studio/Tango.Emulations/EmulatorBase.cs @@ -152,7 +152,7 @@ namespace Tango.Emulations /// </summary> /// <param name="sender">The sender.</param> /// <param name="container">The container.</param> - protected abstract void OnTransporterRequestReceived(object sender, MessageContainer container); + protected abstract void OnTransporterRequestReceived(object sender, RequestReceivedEventArgs e); #endregion diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs index 40900f9b4..5e41146f0 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MachineEmulator.cs @@ -248,8 +248,10 @@ namespace Tango.Emulations.Emulators /// </summary> /// <param name="sender">The sender.</param> /// <param name="container">The container.</param> - protected override void OnTransporterRequestReceived(object sender, MessageContainer container) + protected override void OnTransporterRequestReceived(object sender, RequestReceivedEventArgs e) { + var container = e.Container; + if (container.Type != MessageType.FileChunkUploadRequest && container.Type != MessageType.FileChunkDownloadRequest) { LogManager.Log(container.Type.ToString().ToWords() + " received." + Environment.NewLine + MessageFactory.ExtractMessageFromContainer(container).ToJsonString()); diff --git a/Software/Visual_Studio/Tango.Emulations/Emulators/MobileEmulator.cs b/Software/Visual_Studio/Tango.Emulations/Emulators/MobileEmulator.cs index 5e645928f..086d256f2 100644 --- a/Software/Visual_Studio/Tango.Emulations/Emulators/MobileEmulator.cs +++ b/Software/Visual_Studio/Tango.Emulations/Emulators/MobileEmulator.cs @@ -41,8 +41,10 @@ namespace Tango.Emulations.Emulators /// </summary> /// <param name="sender">The sender.</param> /// <param name="container">The container.</param> - protected override void OnTransporterRequestReceived(object sender, MessageContainer container) + protected override void OnTransporterRequestReceived(object sender, RequestReceivedEventArgs e) { + var container = e.Container; + switch (container.Type) { case MessageType.CalculateRequest: diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs index a2f33e1e0..7f9a91651 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeReceiver.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Net.Sockets; using System.Security.Authentication; using System.Text; +using System.Threading; using System.Threading.Tasks; using Tango.Core; using Tango.Core.ExtensionMethods; @@ -159,12 +160,30 @@ namespace Tango.Integration.ExternalBridge #region Override Methods - protected override void OnRequestReceived(MessageContainer container) + protected override void OnRequestReceived(RequestReceivedEventArgs e) { - base.OnRequestReceived(container); + base.OnRequestReceived(e); + + if (e.Handled) return; + + var container = e.Container; try { + if (e.Container.Type == MessageType.ConfigureProtocolRequest) + { + var message = MessageFactory.ParseTangoMessageFromContainer<ConfigureProtocolRequest>(container); + SendResponse(new ConfigureProtocolResponse() { Confirmed = true }, container.Token, new TransportResponseConfig() { Immediate = true, Priority = QueuePriority.High }); + + Task.Factory.StartNew(() => + { + Thread.Sleep(200); + Adapter.EnableCompression = message.Message.EnableCompression; + GenericProtocol = message.Message.GenericProtocol; + }); + return; + } + if (!AllowSafetyLevelOperations) { if (ExternalBridgeService.SafetyLevelOperations.Contains(container.Type)) diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs index 58487985b..8bf8b1c58 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeScanner.cs @@ -245,11 +245,11 @@ namespace Tango.Integration.ExternalBridge if (knownMachine == null) { - newMachine = new ExternalBridgeTcpClient(packet.SerialNumber, address, packet.CompressionEnabled); + newMachine = new ExternalBridgeTcpClient(packet.SerialNumber, address); } else { - newMachine = new ExternalBridgeTcpClient(knownMachine, address, packet.CompressionEnabled); + newMachine = new ExternalBridgeTcpClient(knownMachine, address); } LogManager.Log("Found a new machine via TCP " + newMachine.SerialNumber); diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs index 438e475a8..5ec806126 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeService.cs @@ -170,11 +170,6 @@ namespace Tango.Integration.ExternalBridge private set { _fullControlSessionReceiver = value; RaisePropertyChangedAuto(); } } - /// <summary> - /// Gets or sets a value indicating whether to broadcast that compression on connected ITransportAdapter is enabled. - /// </summary> - public bool EnableTransportCompression { get; set; } - #endregion #region Constructors @@ -239,7 +234,6 @@ namespace Tango.Integration.ExternalBridge _discoveryService = new UdpDiscoveryService<ExternalBridgeUdpDiscoveryPacket>(_discovery_port, new ExternalBridgeUdpDiscoveryPacket() { SerialNumber = Machine.SerialNumber, - CompressionEnabled = EnableTransportCompression, }); _discoveryService.BeforeBroadcasting -= _discoverySevice_BeforeBroadcasting; @@ -278,7 +272,6 @@ namespace Tango.Integration.ExternalBridge { LogManager.Log("External bridge TCP client connected from: " + e.Socket.GetIPAddress()); ExternalBridgeReceiver receiver = new ExternalBridgeReceiver(e.Socket, MachineOperator); - receiver.Adapter.EnableCompression = EnableTransportCompression; (receiver.Adapter as TcpTransportAdapter).WriteMode = TcpTransportAdapterWriteMode; receiver.LoginRequest += Receiver_LoginRequest; receiver.ColorProfileRequest += Receiver_ColorProfileRequest; @@ -296,7 +289,6 @@ namespace Tango.Integration.ExternalBridge LogManager.Log("External bridge SignalR client connected."); var adapter = new SignalRTransportAdapter(SignalRConfiguration.Address, SignalRConfiguration.Hub, SignalRTransportAdapterMode.JoinSession, Machine.SerialNumber, sessionID); ; - adapter.EnableCompression = EnableTransportCompression; ExternalBridgeReceiver receiver = new ExternalBridgeReceiver(adapter, MachineOperator); receiver.LoginRequest += Receiver_LoginRequest; @@ -432,6 +424,8 @@ namespace Tango.Integration.ExternalBridge private void Receiver_ReceiverRequestReceived(object sender, ExternalBridgeReceiverRequestReceivedEventArgs e) { + ExternalBridgeReceiver receiver = sender as ExternalBridgeReceiver; + if (e.Container.Type == MessageType.GenericRequest || _requestHandlers.ContainsKey(e.Container.Type.ToString())) { e.Handled = true; @@ -465,59 +459,70 @@ namespace Tango.Integration.ExternalBridge }); } } - else //Handle GenericRequest with inner JSON formated generic message. + else //Handle GenericRequest with inner JSON/BSON formated generic message. { var genericType = Type.GetType((message as GenericRequest).Type); - try + if (genericType != null) { - if (_requestHandlers.ContainsKey(genericType.FullName)) + try { - var innerMessage = GenericMessageSerializer.DeserializeFromByteString(genericType, (message as GenericRequest).Data); - - var handler = _requestHandlers[genericType.FullName]; - - if (handler.LoggingMode == RequestHandlerLoggingMode.LogRequestName || handler.LoggingMode == RequestHandlerLoggingMode.LogRequestNameAndContent) + if (_requestHandlers.ContainsKey(genericType.FullName)) { - String content = "."; + var innerMessage = GenericMessageSerializer.DeserializeFromByteString(genericType, (message as GenericRequest).Data, receiver.GenericProtocol); + + var handler = _requestHandlers[genericType.FullName]; - if (handler.LoggingMode == RequestHandlerLoggingMode.LogRequestNameAndContent) + if (handler.LoggingMode == RequestHandlerLoggingMode.LogRequestName || handler.LoggingMode == RequestHandlerLoggingMode.LogRequestNameAndContent) { - content = $":\n{innerMessage.ToJsonString()}"; - } + String content = "."; - LogManager.Log($"'{innerMessage.GetType().Name}' received on '{handler.Method.DeclaringType.Name}.{handler.Method.Name}'{content}"); - } + if (handler.LoggingMode == RequestHandlerLoggingMode.LogRequestNameAndContent) + { + content = $":\n{innerMessage.ToJsonString()}"; + } - if (handler.Method.ReturnType == typeof(Task)) - { - ((Task)handler.Method.Invoke(handler.Handler, new object[] + LogManager.Log($"'{innerMessage.GetType().Name}' received on '{handler.Method.DeclaringType.Name}.{handler.Method.Name}'{content}"); + } + + if (handler.Method.ReturnType == typeof(Task)) { + ((Task)handler.Method.Invoke(handler.Handler, new object[] + { innerMessage, e.Container.Token, sender, - })).Wait(); - } - else - { - handler.Method.Invoke(handler.Handler, new object[] + })).Wait(); + } + else { + handler.Method.Invoke(handler.Handler, new object[] + { innerMessage, e.Container.Token, sender, - }); + }); + } + } + else + { + receiver.SendErrorResponse(new NotSupportedException("Request message not supported on this PPC version."), e.Container.Token); } } - } - catch (Exception ex) - { - LogManager.Log(ex.GetFirstIfAggregate(), $"Error invoking external bridge handler for request '{genericType.Name}'."); - - try + catch (Exception ex) { - (sender as ITransporter).SendErrorResponse(ex.GetFirstIfAggregate(), e.Container.Token); + LogManager.Log(ex.GetFirstIfAggregate(), $"Error invoking external bridge handler for request '{genericType.Name}'."); + + try + { + receiver.SendErrorResponse(ex.GetFirstIfAggregate(), e.Container.Token); + } + catch { } } - catch { } + } + else + { + receiver.SendErrorResponse(new NotSupportedException("Request message not supported on this PPC version."), e.Container.Token); } } } @@ -526,7 +531,7 @@ namespace Tango.Integration.ExternalBridge LogManager.Log(ex, $"An error occurred while trying or invoking an external bridge request handler for '{e.Container.Type}'."); try { - (sender as ITransporter).SendErrorResponse(ex.GetFirstIfAggregate(), e.Container.Token); + receiver.SendErrorResponse(ex.GetFirstIfAggregate(), e.Container.Token); } catch { } } @@ -611,7 +616,6 @@ namespace Tango.Integration.ExternalBridge { SerialNumber = Machine.SerialNumber, Organization = Machine.Organization.Name, - CompressionEnabled = EnableTransportCompression }); _isSignalRConnected = true; diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs index 7c5fc5053..9ad789c06 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeSignalRClient.cs @@ -19,17 +19,12 @@ namespace Tango.Integration.ExternalBridge { public ExternalBridgeSignalRClient(String url, String hub, MachineInfo machineInfo) { - CompressionEnabled = machineInfo.CompressionEnabled; - ComponentName = $"External Bridge SignalR Client {_component_counter++}"; SerialNumber = machineInfo.SerialNumber; IPAddress = machineInfo.IPAddress; Machine = ObservablesStaticCollections.Instance.Machines.SingleOrDefault(x => x.SerialNumber == SerialNumber); - Adapter = new SignalRTransportAdapter(url, hub, SignalRTransportAdapterMode.CreateSession, SerialNumber, null, IPAddress) - { - EnableCompression = CompressionEnabled - }; + Adapter = new SignalRTransportAdapter(url, hub, SignalRTransportAdapterMode.CreateSession, SerialNumber, null, IPAddress); KeepAliveTimeout = TimeSpan.FromSeconds(5); KeepAliveRetries = 2; @@ -38,24 +33,26 @@ namespace Tango.Integration.ExternalBridge public ExternalBridgeSignalRClient(String url, String hub, Machine machine, MachineInfo machineInfo) { - CompressionEnabled = machineInfo.CompressionEnabled; - ComponentName = $"External Bridge SignalR Client {_component_counter++}"; SerialNumber = machine.SerialNumber; IPAddress = machineInfo.IPAddress; Machine = machine; - Adapter = new SignalRTransportAdapter(url, hub, SignalRTransportAdapterMode.CreateSession, SerialNumber, null, IPAddress) - { - EnableCompression = CompressionEnabled - }; + Adapter = new SignalRTransportAdapter(url, hub, SignalRTransportAdapterMode.CreateSession, SerialNumber, null, IPAddress); KeepAliveTimeout = TimeSpan.FromSeconds(5); KeepAliveRetries = 2; UseKeepAlive = false; } - public override async Task Connect(ExternalBridgeLoginRequest login) + /// <summary> + /// Connects to a remote external bridge service using the specified login. + /// </summary> + /// <param name="login">The login request.</param> + /// <param name="protocol">Optional protocol configuration.</param> + /// <returns></returns> + /// <exception cref="AuthenticationException"></exception> + public override async Task Connect(ExternalBridgeLoginRequest login, ConfigureProtocolRequest protocol = null) { if (State != TransportComponentState.Connected) { @@ -66,7 +63,7 @@ namespace Tango.Integration.ExternalBridge State = TransportComponentState.Connected; StartThreads(); - LogManager.Log("External Bridge SignalR Client Connected..."); + LogManager.Log($"{ComponentName}: External Bridge SignalR Client Connected..."); TimeSpan? timeout = null; @@ -77,6 +74,24 @@ namespace Tango.Integration.ExternalBridge var response = await SendRequest<ExternalBridgeLoginRequest, ExternalBridgeLoginResponse>(login, new TransportRequestConfig() { ShouldLog = true, Timeout = timeout }); + if (protocol != null) + { + try + { + var configureResponse = await SendRequest<ConfigureProtocolRequest, ConfigureProtocolResponse>(protocol, new TransportRequestConfig() { ShouldLog = true }); + if (configureResponse.Message.Confirmed) + { + await Task.Delay(500); + Adapter.EnableCompression = protocol.EnableCompression; + GenericProtocol = protocol.GenericProtocol; + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"{ComponentName}: Could not configure remote machine protocol. Could be an old PPC version."); + } + } + ApplicationInformation = response.Message.ApplicationInformation; SessionLogger.CreateSession(); diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs index 2a6fa1aad..210db008d 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/ExternalBridgeTcpClient.cs @@ -59,11 +59,6 @@ namespace Tango.Integration.ExternalBridge set { _ipAddress = value; RaisePropertyChangedAuto(); } } - /// <summary> - /// Gets or sets a value indicating whether transport compression is required by the remote machine. - /// </summary> - public bool CompressionEnabled { get; set; } - private bool _enableApplicationLogs; /// <summary> /// Gets or sets a value indicating whether to enable receiving application logs. @@ -91,6 +86,11 @@ namespace Tango.Integration.ExternalBridge /// </summary> public ExternalBridgeLoginRequest LoginRequest { get; set; } + /// <summary> + /// Gets or sets the configure protocol request message when using <see cref="Connect"/>. + /// </summary> + public ConfigureProtocolRequest ConfigureProtocolRequest { get; set; } + private ApplicationInformation _applicationInformation; /// <summary> /// Gets or sets the remote application information (PPC). @@ -115,16 +115,17 @@ namespace Tango.Integration.ExternalBridge { throw new InvalidOperationException("No LoginRequest was not specified."); } - return Connect(LoginRequest); + return Connect(LoginRequest, ConfigureProtocolRequest); } /// <summary> /// Connects to a remote external bridge service using the specified login. /// </summary> - /// <param name="login">The login.</param> + /// <param name="login">The login request.</param> + /// <param name="protocol">Optional protocol configuration.</param> /// <returns></returns> - /// <exception cref="AuthenticationException">The machine password is invalid.</exception> - public virtual async Task Connect(ExternalBridgeLoginRequest login) + /// <exception cref="AuthenticationException"></exception> + public virtual async Task Connect(ExternalBridgeLoginRequest login, ConfigureProtocolRequest protocol = null) { if (State != TransportComponentState.Connected) { @@ -135,7 +136,7 @@ namespace Tango.Integration.ExternalBridge State = TransportComponentState.Connected; StartThreads(); - LogManager.Log("External Bridge TCP Client Connected..."); + LogManager.Log($"{ComponentName}: External Bridge TCP Client Connected..."); TimeSpan? timeout = null; @@ -146,6 +147,24 @@ namespace Tango.Integration.ExternalBridge var response = await SendRequest<ExternalBridgeLoginRequest, ExternalBridgeLoginResponse>(login, new TransportRequestConfig() { ShouldLog = true, Timeout = timeout }); + if (protocol != null) + { + try + { + var configureResponse = await SendRequest<ConfigureProtocolRequest, ConfigureProtocolResponse>(protocol, new TransportRequestConfig() { ShouldLog = true }); + if (configureResponse.Message.Confirmed) + { + await Task.Delay(500); + Adapter.EnableCompression = protocol.EnableCompression; + GenericProtocol = protocol.GenericProtocol; + } + } + catch (Exception ex) + { + LogManager.Log(ex, $"{ComponentName}: Could not configure remote machine protocol. Could be an old PPC version."); + } + } + ApplicationInformation = response.Message.ApplicationInformation; SessionLogger.CreateSession(); @@ -286,11 +305,10 @@ namespace Tango.Integration.ExternalBridge /// </summary> /// <param name="serialNumber">The machine serial number.</param> /// <param name="ipAddress">The machine IP address.</param> - public ExternalBridgeTcpClient(String serialNumber, String ipAddress, bool enableCompression) + public ExternalBridgeTcpClient(String serialNumber, String ipAddress) { ComponentName = $"External Bridge TCP Client {_component_counter++}"; SerialNumber = serialNumber; - CompressionEnabled = enableCompression; if (ObservablesStaticCollections.Instance.IsInitialized) { @@ -302,28 +320,21 @@ namespace Tango.Integration.ExternalBridge UseKeepAlive = false; EnableDiagnostics = true; - Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.GetOrCreate<IntegrationSettings>().ExternalBridgeServicePort) - { - EnableCompression = CompressionEnabled - }; + Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.GetOrCreate<IntegrationSettings>().ExternalBridgeServicePort); } - public ExternalBridgeTcpClient(Machine machine, String ipAddress, bool enableCompression) + public ExternalBridgeTcpClient(Machine machine, String ipAddress) { ComponentName = $"External Bridge TCP Client {_component_counter++}"; Machine = machine; SerialNumber = Machine.SerialNumber; - CompressionEnabled = enableCompression; IPAddress = ipAddress; KeepAliveTimeout = TimeSpan.FromSeconds(5); KeepAliveRetries = 2; UseKeepAlive = false; EnableDiagnostics = true; - Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.GetOrCreate<IntegrationSettings>().ExternalBridgeServicePort) - { - EnableCompression = CompressionEnabled - }; + Adapter = new TcpTransportAdapter(IPAddress, SettingsManager.Default.GetOrCreate<IntegrationSettings>().ExternalBridgeServicePort); } /// <summary> @@ -341,15 +352,17 @@ namespace Tango.Integration.ExternalBridge /// Called when a new request has been received. /// </summary> /// <param name="request">The request.</param> - protected async override void OnRequestReceived(MessageContainer request) + protected async override void OnRequestReceived(RequestReceivedEventArgs e) { - base.OnRequestReceived(request); + base.OnRequestReceived(e); + + var container = e.Container; - if (request.Type == MessageType.ExternalBridgeLogoutRequest) + if (container.Type == MessageType.ExternalBridgeLogoutRequest) { try { - await SendResponse<ExternalBridgeLogoutResponse>(new ExternalBridgeLogoutResponse(), request.Token); + await SendResponse<ExternalBridgeLogoutResponse>(new ExternalBridgeLogoutResponse(), container.Token); } catch { } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeClient.cs index 563ef9418..d336b6b70 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeClient.cs @@ -28,11 +28,6 @@ namespace Tango.Integration.ExternalBridge String SerialNumber { get; set; } /// <summary> - /// Gets or sets a value indicating whether transport compression is required by the remote machine. - /// </summary> - bool CompressionEnabled { get; set; } - - /// <summary> /// Gets the database machine associated with this client. /// </summary> Machine Machine { get; } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeSecureClient.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeSecureClient.cs index 7d35963d4..aaf7efc2d 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeSecureClient.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeSecureClient.cs @@ -21,8 +21,9 @@ namespace Tango.Integration.ExternalBridge /// <summary> /// Connects to a remote external bridge service using the specified login. /// </summary> - /// <param name="login">The login.</param> + /// <param name="login">The login request.</param> + /// <param name="protocol">Optional protocol configuration.</param> /// <returns></returns> - Task Connect(ExternalBridgeLoginRequest login); + Task Connect(ExternalBridgeLoginRequest login, ConfigureProtocolRequest protocol = null); } } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeService.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeService.cs index f6a4ca110..c7d2c8d5c 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeService.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/IExternalBridgeService.cs @@ -62,11 +62,6 @@ namespace Tango.Integration.ExternalBridge TcpTransportAdapterWriteMode TcpTransportAdapterWriteMode { get; set; } /// <summary> - /// Gets or sets a value indicating whether to broadcast that compression on connected ITransportAdapter is enabled. - /// </summary> - bool EnableTransportCompression { get; set; } - - /// <summary> /// Gets a value indicating whether this instance is started. /// </summary> bool IsStarted { get; } diff --git a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Web/MachineInfo.cs b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Web/MachineInfo.cs index 578dd9640..cccc24c35 100644 --- a/Software/Visual_Studio/Tango.Integration/ExternalBridge/Web/MachineInfo.cs +++ b/Software/Visual_Studio/Tango.Integration/ExternalBridge/Web/MachineInfo.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; +using Tango.PMR.Integration; +using Tango.Transport; namespace Tango.Integration.ExternalBridge.Web { @@ -11,7 +13,6 @@ namespace Tango.Integration.ExternalBridge.Web public String SerialNumber { get; set; } public String Organization { get; set; } public String IPAddress { get; set; } - public bool CompressionEnabled { get; set; } public MachineInfo() { diff --git a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs index a95d34e96..8e7306ba9 100644 --- a/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs +++ b/Software/Visual_Studio/Tango.Integration/Operation/MachineOperator.cs @@ -1018,16 +1018,22 @@ namespace Tango.Integration.Operation /// Called when a new request has been received. /// </summary> /// <param name="container">The request.</param> - protected override void OnRequestReceived(MessageContainer container) + protected override void OnRequestReceived(RequestReceivedEventArgs e) { - base.OnRequestReceived(container); + base.OnRequestReceived(e); + + if (e.Handled) return; + + var container = e.Container; if (container.Type == MessageType.CartridgeValidationRequest) { + e.Handled = true; OnCartridgeValidationRequestReceived(container.Token, MessageFactory.ExtractMessageFromContainer<CartridgeValidationRequest>(container)); } else if (container.Type == MessageType.UpdateStatusRequest) { + e.Handled = true; OnUpdateStatusRequestReceived(container.Token, MessageFactory.ExtractMessageFromContainer<UpdateStatusRequest>(container)); } } diff --git a/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs b/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs index 8bc3729f2..fc791ff4a 100644 --- a/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs +++ b/Software/Visual_Studio/Tango.Logging/GlobalExceptionTrapper.cs @@ -88,7 +88,6 @@ namespace Tango.Logging { if (DateTime.Now < _lastGlobalExceptionTime.AddSeconds(1)) { - LogManager.Default.Log(exception, LogCategory.Critical); _lastGlobalExceptionTime = DateTime.Now; return true; } diff --git a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs index 088ceb863..4ad2ae9c6 100644 --- a/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs +++ b/Software/Visual_Studio/Tango.PMR/Common/MessageType.cs @@ -22,7 +22,7 @@ namespace Tango.PMR.Common { static MessageTypeReflection() { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( - "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbiqGPAoLTWVz", + "ChFNZXNzYWdlVHlwZS5wcm90bxIQVGFuZ28uUE1SLkNvbW1vbirFPAoLTWVz", "c2FnZVR5cGUSCAoETm9uZRAAEhEKDUVycm9yUmVzcG9uc2UQARIUChBDYWxj", "dWxhdGVSZXF1ZXN0EAMSFQoRQ2FsY3VsYXRlUmVzcG9uc2UQBBITCg9Qcm9n", "cmVzc1JlcXVlc3QQBRIUChBQcm9ncmVzc1Jlc3BvbnNlEAYSHAoYU3R1YkNh", @@ -108,93 +108,94 @@ namespace Tango.PMR.Common { "b2ZpbGVSZXF1ZXN0EPUHEhkKFENvbG9yUHJvZmlsZVJlc3BvbnNlEPYHEhgK", "E1VwZGF0ZVN0YXR1c1JlcXVlc3QQ9wcSGQoUVXBkYXRlU3RhdHVzUmVzcG9u", "c2UQ+AcSEwoOR2VuZXJpY1JlcXVlc3QQ+QcSFAoPR2VuZXJpY1J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SZXNwb25zZRCRThIaChVBYm9ydFBvd2Vy", + "RG93blJlcXVlc3QQkk4SGwoWQWJvcnRQb3dlckRvd25SZXNwb25zZRCTThIY", + "ChNTdGFydFBvd2VyVXBSZXF1ZXN0EJROEhkKFFN0YXJ0UG93ZXJVcFJlc3Bv", + "bnNlEJVOEhgKE0Fib3J0UG93ZXJVcFJlcXVlc3QQlk4SGQoUQWJvcnRQb3dl", + "clVwUmVzcG9uc2UQl04SHgoZU3RhcnRUaHJlYWRMb2FkaW5nUmVxdWVzdBD4", + "VRIfChpTdGFydFRocmVhZExvYWRpbmdSZXNwb25zZRD5VRIhChxDb250aW51", + "ZVRocmVhZExvYWRpbmdSZXF1ZXN0EPpVEiIKHUNvbnRpbnVlVGhyZWFkTG9h", + "ZGluZ1Jlc3BvbnNlEPtVEh0KGFN0b3BUaHJlYWRMb2FkaW5nUmVxdWVzdBD8", + "VRIeChlTdG9wVGhyZWFkTG9hZGluZ1Jlc3BvbnNlEP1VEhwKF1RyeVRocmVh", + "ZExvYWRpbmdSZXF1ZXN0EP5VEh0KGFRyeVRocmVhZExvYWRpbmdSZXNwb25z", + "ZRD/VUIcChpjb20udHdpbmUudGFuZ28ucG1yLmNvbW1vbmIGcHJvdG8z")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Common.MessageType), }, null)); @@ -350,6 +351,8 @@ namespace Tango.PMR.Common { [pbr::OriginalName("UpdateStatusResponse")] UpdateStatusResponse = 1016, [pbr::OriginalName("GenericRequest")] GenericRequest = 1017, [pbr::OriginalName("GenericResponse")] GenericResponse = 1018, + [pbr::OriginalName("ConfigureProtocolRequest")] ConfigureProtocolRequest = 1019, + [pbr::OriginalName("ConfigureProtocolResponse")] ConfigureProtocolResponse = 1020, /// <summary> ///Diagnostics /// </summary> diff --git a/Software/Visual_Studio/Tango.PMR/Integration/ConfigureProtocolRequest.cs b/Software/Visual_Studio/Tango.PMR/Integration/ConfigureProtocolRequest.cs new file mode 100644 index 000000000..7cb3ffefe --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Integration/ConfigureProtocolRequest.cs @@ -0,0 +1,190 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ConfigureProtocolRequest.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Integration { + + /// <summary>Holder for reflection information generated from ConfigureProtocolRequest.proto</summary> + public static partial class ConfigureProtocolRequestReflection { + + #region Descriptor + /// <summary>File descriptor for ConfigureProtocolRequest.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ConfigureProtocolRequestReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch5Db25maWd1cmVQcm90b2NvbFJlcXVlc3QucHJvdG8SFVRhbmdvLlBNUi5J", + "bnRlZ3JhdGlvbhocR2VuZXJpY01lc3NhZ2VQcm90b2NvbC5wcm90byJ9ChhD", + "b25maWd1cmVQcm90b2NvbFJlcXVlc3QSGQoRRW5hYmxlQ29tcHJlc3Npb24Y", + "ASABKAgSRgoPR2VuZXJpY1Byb3RvY29sGAIgASgOMi0uVGFuZ28uUE1SLklu", + "dGVncmF0aW9uLkdlbmVyaWNNZXNzYWdlUHJvdG9jb2xCIQofY29tLnR3aW5l", + "LnRhbmdvLnBtci5pbnRlZ3JhdGlvbmIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { global::Tango.PMR.Integration.GenericMessageProtocolReflection.Descriptor, }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Integration.ConfigureProtocolRequest), global::Tango.PMR.Integration.ConfigureProtocolRequest.Parser, new[]{ "EnableCompression", "GenericProtocol" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class ConfigureProtocolRequest : pb::IMessage<ConfigureProtocolRequest> { + private static readonly pb::MessageParser<ConfigureProtocolRequest> _parser = new pb::MessageParser<ConfigureProtocolRequest>(() => new ConfigureProtocolRequest()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ConfigureProtocolRequest> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Integration.ConfigureProtocolRequestReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ConfigureProtocolRequest() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ConfigureProtocolRequest(ConfigureProtocolRequest other) : this() { + enableCompression_ = other.enableCompression_; + genericProtocol_ = other.genericProtocol_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ConfigureProtocolRequest Clone() { + return new ConfigureProtocolRequest(this); + } + + /// <summary>Field number for the "EnableCompression" field.</summary> + public const int EnableCompressionFieldNumber = 1; + private bool enableCompression_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool EnableCompression { + get { return enableCompression_; } + set { + enableCompression_ = value; + } + } + + /// <summary>Field number for the "GenericProtocol" field.</summary> + public const int GenericProtocolFieldNumber = 2; + private global::Tango.PMR.Integration.GenericMessageProtocol genericProtocol_ = 0; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public global::Tango.PMR.Integration.GenericMessageProtocol GenericProtocol { + get { return genericProtocol_; } + set { + genericProtocol_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ConfigureProtocolRequest); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ConfigureProtocolRequest other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (EnableCompression != other.EnableCompression) return false; + if (GenericProtocol != other.GenericProtocol) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (EnableCompression != false) hash ^= EnableCompression.GetHashCode(); + if (GenericProtocol != 0) hash ^= GenericProtocol.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (EnableCompression != false) { + output.WriteRawTag(8); + output.WriteBool(EnableCompression); + } + if (GenericProtocol != 0) { + output.WriteRawTag(16); + output.WriteEnum((int) GenericProtocol); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (EnableCompression != false) { + size += 1 + 1; + } + if (GenericProtocol != 0) { + size += 1 + pb::CodedOutputStream.ComputeEnumSize((int) GenericProtocol); + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ConfigureProtocolRequest other) { + if (other == null) { + return; + } + if (other.EnableCompression != false) { + EnableCompression = other.EnableCompression; + } + if (other.GenericProtocol != 0) { + GenericProtocol = other.GenericProtocol; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + EnableCompression = input.ReadBool(); + break; + } + case 16: { + genericProtocol_ = (global::Tango.PMR.Integration.GenericMessageProtocol) input.ReadEnum(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Integration/ConfigureProtocolResponse.cs b/Software/Visual_Studio/Tango.PMR/Integration/ConfigureProtocolResponse.cs new file mode 100644 index 000000000..750430f32 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Integration/ConfigureProtocolResponse.cs @@ -0,0 +1,160 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: ConfigureProtocolResponse.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Integration { + + /// <summary>Holder for reflection information generated from ConfigureProtocolResponse.proto</summary> + public static partial class ConfigureProtocolResponseReflection { + + #region Descriptor + /// <summary>File descriptor for ConfigureProtocolResponse.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static ConfigureProtocolResponseReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "Ch9Db25maWd1cmVQcm90b2NvbFJlc3BvbnNlLnByb3RvEhVUYW5nby5QTVIu", + "SW50ZWdyYXRpb24iLgoZQ29uZmlndXJlUHJvdG9jb2xSZXNwb25zZRIRCglD", + "b25maXJtZWQYASABKAhCIQofY29tLnR3aW5lLnRhbmdvLnBtci5pbnRlZ3Jh", + "dGlvbmIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Integration.ConfigureProtocolResponse), global::Tango.PMR.Integration.ConfigureProtocolResponse.Parser, new[]{ "Confirmed" }, null, null, null) + })); + } + #endregion + + } + #region Messages + public sealed partial class ConfigureProtocolResponse : pb::IMessage<ConfigureProtocolResponse> { + private static readonly pb::MessageParser<ConfigureProtocolResponse> _parser = new pb::MessageParser<ConfigureProtocolResponse>(() => new ConfigureProtocolResponse()); + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pb::MessageParser<ConfigureProtocolResponse> Parser { get { return _parser; } } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public static pbr::MessageDescriptor Descriptor { + get { return global::Tango.PMR.Integration.ConfigureProtocolResponseReflection.Descriptor.MessageTypes[0]; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + pbr::MessageDescriptor pb::IMessage.Descriptor { + get { return Descriptor; } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ConfigureProtocolResponse() { + OnConstruction(); + } + + partial void OnConstruction(); + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ConfigureProtocolResponse(ConfigureProtocolResponse other) : this() { + confirmed_ = other.confirmed_; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public ConfigureProtocolResponse Clone() { + return new ConfigureProtocolResponse(this); + } + + /// <summary>Field number for the "Confirmed" field.</summary> + public const int ConfirmedFieldNumber = 1; + private bool confirmed_; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Confirmed { + get { return confirmed_; } + set { + confirmed_ = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override bool Equals(object other) { + return Equals(other as ConfigureProtocolResponse); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public bool Equals(ConfigureProtocolResponse other) { + if (ReferenceEquals(other, null)) { + return false; + } + if (ReferenceEquals(other, this)) { + return true; + } + if (Confirmed != other.Confirmed) return false; + return true; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override int GetHashCode() { + int hash = 1; + if (Confirmed != false) hash ^= Confirmed.GetHashCode(); + return hash; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public override string ToString() { + return pb::JsonFormatter.ToDiagnosticString(this); + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void WriteTo(pb::CodedOutputStream output) { + if (Confirmed != false) { + output.WriteRawTag(8); + output.WriteBool(Confirmed); + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public int CalculateSize() { + int size = 0; + if (Confirmed != false) { + size += 1 + 1; + } + return size; + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(ConfigureProtocolResponse other) { + if (other == null) { + return; + } + if (other.Confirmed != false) { + Confirmed = other.Confirmed; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute] + public void MergeFrom(pb::CodedInputStream input) { + uint tag; + while ((tag = input.ReadTag()) != 0) { + switch(tag) { + default: + input.SkipLastField(); + break; + case 8: { + Confirmed = input.ReadBool(); + break; + } + } + } + } + + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs b/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs index 69d835521..df584d5c6 100644 --- a/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs +++ b/Software/Visual_Studio/Tango.PMR/Integration/ExternalBridgeUdpDiscoveryPacket.cs @@ -23,14 +23,13 @@ namespace Tango.PMR.Integration { byte[] descriptorData = global::System.Convert.FromBase64String( string.Concat( "CiZFeHRlcm5hbEJyaWRnZVVkcERpc2NvdmVyeVBhY2tldC5wcm90bxIVVGFu", - "Z28uUE1SLkludGVncmF0aW9uImIKIEV4dGVybmFsQnJpZGdlVWRwRGlzY292", + "Z28uUE1SLkludGVncmF0aW9uIkYKIEV4dGVybmFsQnJpZGdlVWRwRGlzY292", "ZXJ5UGFja2V0EgwKBFRpbWUYASABKAkSFAoMU2VyaWFsTnVtYmVyGAIgASgJ", - "EhoKEkNvbXByZXNzaW9uRW5hYmxlZBgDIAEoCEIhCh9jb20udHdpbmUudGFu", - "Z28ucG1yLmludGVncmF0aW9uYgZwcm90bzM=")); + "QiEKH2NvbS50d2luZS50YW5nby5wbXIuaW50ZWdyYXRpb25iBnByb3RvMw==")); descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, new pbr::FileDescriptor[] { }, new pbr::GeneratedClrTypeInfo(null, new pbr::GeneratedClrTypeInfo[] { - new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket), global::Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket.Parser, new[]{ "Time", "SerialNumber", "CompressionEnabled" }, null, null, null) + new pbr::GeneratedClrTypeInfo(typeof(global::Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket), global::Tango.PMR.Integration.ExternalBridgeUdpDiscoveryPacket.Parser, new[]{ "Time", "SerialNumber" }, null, null, null) })); } #endregion @@ -63,7 +62,6 @@ namespace Tango.PMR.Integration { public ExternalBridgeUdpDiscoveryPacket(ExternalBridgeUdpDiscoveryPacket other) : this() { time_ = other.time_; serialNumber_ = other.serialNumber_; - compressionEnabled_ = other.compressionEnabled_; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -93,17 +91,6 @@ namespace Tango.PMR.Integration { } } - /// <summary>Field number for the "CompressionEnabled" field.</summary> - public const int CompressionEnabledFieldNumber = 3; - private bool compressionEnabled_; - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] - public bool CompressionEnabled { - get { return compressionEnabled_; } - set { - compressionEnabled_ = value; - } - } - [global::System.Diagnostics.DebuggerNonUserCodeAttribute] public override bool Equals(object other) { return Equals(other as ExternalBridgeUdpDiscoveryPacket); @@ -119,7 +106,6 @@ namespace Tango.PMR.Integration { } if (Time != other.Time) return false; if (SerialNumber != other.SerialNumber) return false; - if (CompressionEnabled != other.CompressionEnabled) return false; return true; } @@ -128,7 +114,6 @@ namespace Tango.PMR.Integration { int hash = 1; if (Time.Length != 0) hash ^= Time.GetHashCode(); if (SerialNumber.Length != 0) hash ^= SerialNumber.GetHashCode(); - if (CompressionEnabled != false) hash ^= CompressionEnabled.GetHashCode(); return hash; } @@ -147,10 +132,6 @@ namespace Tango.PMR.Integration { output.WriteRawTag(18); output.WriteString(SerialNumber); } - if (CompressionEnabled != false) { - output.WriteRawTag(24); - output.WriteBool(CompressionEnabled); - } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -162,9 +143,6 @@ namespace Tango.PMR.Integration { if (SerialNumber.Length != 0) { size += 1 + pb::CodedOutputStream.ComputeStringSize(SerialNumber); } - if (CompressionEnabled != false) { - size += 1 + 1; - } return size; } @@ -179,9 +157,6 @@ namespace Tango.PMR.Integration { if (other.SerialNumber.Length != 0) { SerialNumber = other.SerialNumber; } - if (other.CompressionEnabled != false) { - CompressionEnabled = other.CompressionEnabled; - } } [global::System.Diagnostics.DebuggerNonUserCodeAttribute] @@ -200,10 +175,6 @@ namespace Tango.PMR.Integration { SerialNumber = input.ReadString(); break; } - case 24: { - CompressionEnabled = input.ReadBool(); - break; - } } } } diff --git a/Software/Visual_Studio/Tango.PMR/Integration/GenericMessageProtocol.cs b/Software/Visual_Studio/Tango.PMR/Integration/GenericMessageProtocol.cs new file mode 100644 index 000000000..35c9fffe5 --- /dev/null +++ b/Software/Visual_Studio/Tango.PMR/Integration/GenericMessageProtocol.cs @@ -0,0 +1,47 @@ +// Generated by the protocol buffer compiler. DO NOT EDIT! +// source: GenericMessageProtocol.proto +#pragma warning disable 1591, 0612, 3021 +#region Designer generated code + +using pb = global::Google.Protobuf; +using pbc = global::Google.Protobuf.Collections; +using pbr = global::Google.Protobuf.Reflection; +using scg = global::System.Collections.Generic; +namespace Tango.PMR.Integration { + + /// <summary>Holder for reflection information generated from GenericMessageProtocol.proto</summary> + public static partial class GenericMessageProtocolReflection { + + #region Descriptor + /// <summary>File descriptor for GenericMessageProtocol.proto</summary> + public static pbr::FileDescriptor Descriptor { + get { return descriptor; } + } + private static pbr::FileDescriptor descriptor; + + static GenericMessageProtocolReflection() { + byte[] descriptorData = global::System.Convert.FromBase64String( + string.Concat( + "ChxHZW5lcmljTWVzc2FnZVByb3RvY29sLnByb3RvEhVUYW5nby5QTVIuSW50", + "ZWdyYXRpb24qOgoWR2VuZXJpY01lc3NhZ2VQcm90b2NvbBIICgRKc29uEAAS", + "CAoEQnNvbhABEgwKCFByb3RvYnVmEAJCIQofY29tLnR3aW5lLnRhbmdvLnBt", + "ci5pbnRlZ3JhdGlvbmIGcHJvdG8z")); + descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData, + new pbr::FileDescriptor[] { }, + new pbr::GeneratedClrTypeInfo(new[] {typeof(global::Tango.PMR.Integration.GenericMessageProtocol), }, null)); + } + #endregion + + } + #region Enums + public enum GenericMessageProtocol { + [pbr::OriginalName("Json")] Json = 0, + [pbr::OriginalName("Bson")] Bson = 1, + [pbr::OriginalName("Protobuf")] Protobuf = 2, + } + + #endregion + +} + +#endregion Designer generated code diff --git a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj index 4ad2e6612..b7e7ddfeb 100644 --- a/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj +++ b/Software/Visual_Studio/Tango.PMR/Tango.PMR.csproj @@ -220,6 +220,8 @@ <Compile Include="Integration\ApplicationInformation.cs" /> <Compile Include="Integration\ColorProfileRequest.cs" /> <Compile Include="Integration\ColorProfileResponse.cs" /> + <Compile Include="Integration\ConfigureProtocolRequest.cs" /> + <Compile Include="Integration\ConfigureProtocolResponse.cs" /> <Compile Include="Integration\DirectSynchronizationRequest.cs" /> <Compile Include="Integration\DirectSynchronizationResponse.cs" /> <Compile Include="Integration\ExternalBridgeLoginIntent.cs" /> @@ -228,6 +230,7 @@ <Compile Include="Integration\ExternalBridgeLogoutRequest.cs" /> <Compile Include="Integration\ExternalBridgeLogoutResponse.cs" /> <Compile Include="Integration\ExternalBridgeUdpDiscoveryPacket.cs" /> + <Compile Include="Integration\GenericMessageProtocol.cs" /> <Compile Include="Integration\GenericRequest.cs" /> <Compile Include="Integration\GenericResponse.cs" /> <Compile Include="Integration\OverrideDataBaseRequest.cs" /> @@ -465,7 +468,7 @@ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/GenericMessageProtocolToStringConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/GenericMessageProtocolToStringConverter.cs new file mode 100644 index 000000000..11b58d3fd --- /dev/null +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/GenericMessageProtocolToStringConverter.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Data; +using Tango.PMR.Integration; + +namespace Tango.SharedUI.Converters +{ + public class GenericMessageProtocolToStringConverter : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + try + { + if (value != null) + { + GenericMessageProtocol protocol = (GenericMessageProtocol)value; + + if (protocol == GenericMessageProtocol.Json) + { + return "v1"; + } + else + { + return "v2"; + } + } + } + catch { } + + return "Unspecified"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs index e1255ef13..da5717875 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs +++ b/Software/Visual_Studio/Tango.SharedUI/Converters/StringToOneLineConverter.cs @@ -34,7 +34,7 @@ namespace Tango.SharedUI.Converters firstline = firstline.Ellipsis(System.Convert.ToInt32(parameter)); } - return firstline; + return firstline.Trim(); } else { diff --git a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj index 2b75d0531..a6980e978 100644 --- a/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj +++ b/Software/Visual_Studio/Tango.SharedUI/Tango.SharedUI.csproj @@ -114,6 +114,7 @@ <Compile Include="Converters\EnumToVisibilityConverter.cs" /> <Compile Include="Converters\EnumToXamlVectorConverter.cs" /> <Compile Include="Converters\FilePathToFileNameConverter.cs" /> + <Compile Include="Converters\GenericMessageProtocolToStringConverter.cs" /> <Compile Include="Converters\IsEqualConverter.cs" /> <Compile Include="Converters\IsEqualToVisibilityConverter.cs" /> <Compile Include="Converters\IsNotConverter.cs" /> @@ -252,6 +253,10 @@ <Project>{b112d89a-a106-41ae-a0c1-4abc84c477f5}</Project> <Name>Tango.DragAndDrop</Name> </ProjectReference> + <ProjectReference Include="..\Tango.PMR\Tango.PMR.csproj"> + <Project>{e4927038-348d-4295-aaf4-861c58cb3943}</Project> + <Name>Tango.PMR</Name> + </ProjectReference> </ItemGroup> <ItemGroup> <Resource Include="Images\PinClose_Black.png" /> @@ -259,7 +264,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs b/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs index f2692426f..c9a2453f0 100644 --- a/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs +++ b/Software/Visual_Studio/Tango.Transport/Adapters/SignalRTransportAdapter.cs @@ -115,7 +115,7 @@ namespace Tango.Transport.Adapters } catch (Exception ex) { - OnFailed(LogManager.Log(ex, $"Error writing to SignalR adapter ({Address}).")); + OnFailed(LogManager.Log(ex, $"{ComponentName}: Error writing to SignalR adapter ({Address}).")); return; } } @@ -129,7 +129,7 @@ namespace Tango.Transport.Adapters { if (State != TransportComponentState.Connected) { - LogManager.Log("Connecting SignalR adapter..."); + LogManager.Log($"{ComponentName}: Connecting SignalR adapter..."); bool completed = false; @@ -158,8 +158,8 @@ namespace Tango.Transport.Adapters { completed = true; - LogManager.Log($"SignalR adapter session created ({SessionID})..."); - LogManager.Log("SingalR adapter connected."); + LogManager.Log($"{ComponentName}: SignalR adapter session created ({SessionID})..."); + LogManager.Log($"{ComponentName}: SingalR adapter connected."); State = TransportComponentState.Connected; StartPushThread(); @@ -171,7 +171,7 @@ namespace Tango.Transport.Adapters { if (!completed) { - LogManager.Log(ex, "Error occurred after session created."); + LogManager.Log(ex, $"{ComponentName}: Error occurred after session created."); completed = true; completionSource.SetException(ex); } @@ -187,14 +187,14 @@ namespace Tango.Transport.Adapters { if (Mode == SignalRTransportAdapterMode.CreateSession) { - LogManager.Log("Creating SignalR adapter Session..."); + LogManager.Log($"{ComponentName}: Creating SignalR adapter Session..."); SessionID = await _proxy.Invoke<String>("CreateSession", SerialNumber); } else { - LogManager.Log($"Joining SignalR adapter session ({SessionID})..."); + LogManager.Log($"{ComponentName}: Joining SignalR adapter session ({SessionID})..."); await _proxy.Invoke("JoinSession", SessionID); - LogManager.Log("SingalR adapter connected."); + LogManager.Log($"{ComponentName}: SingalR adapter connected."); } if (Mode == SignalRTransportAdapterMode.JoinSession) @@ -214,7 +214,7 @@ namespace Tango.Transport.Adapters if (!completed) { completed = true; - LogManager.Log(ex, "Error occurred on connection state changed event."); + LogManager.Log(ex, $"{ComponentName}: Error occurred on connection state changed event."); completionSource.SetException(ex); } } @@ -239,7 +239,7 @@ namespace Tango.Transport.Adapters { if (State == TransportComponentState.Connected) { - LogManager.Log("Disconnecting SignalR adapter..."); + LogManager.Log($"{ComponentName}: Disconnecting SignalR adapter..."); Core.Threading.TimeoutTask.StartNew(() => { try @@ -258,11 +258,11 @@ namespace Tango.Transport.Adapters } catch (Exception ex) { - LogManager.Log(ex, "Error disposing SignalR adapter connection."); + LogManager.Log(ex, $"{ComponentName}: Error disposing SignalR adapter connection."); } }, TimeSpan.FromSeconds(5)); - LogManager.Log("SignalR adapter disconnected."); + LogManager.Log($"{ComponentName}: SignalR adapter disconnected."); State = TransportComponentState.Disconnected; } }); @@ -315,7 +315,7 @@ namespace Tango.Transport.Adapters } catch (Exception ex) { - OnFailed(LogManager.Log(ex, $"Error writing to SignalR adapter ({Address}).")); + OnFailed(LogManager.Log(ex, $"{ComponentName}: Error writing to SignalR adapter ({Address}).")); return; } } @@ -332,17 +332,40 @@ namespace Tango.Transport.Adapters /// <param name="dataCollection">The data collection.</param> private void OnDataAvailable(List<byte[]> dataCollection) { - foreach (var data in dataCollection) + try { - if (EnableCompression) - { - OnDataAvailable(Compression.GZipHelper.Decompress(data)); - } - else + foreach (var data in dataCollection) { - OnDataAvailable(data); + if (EnableCompression) + { + try + { + var decompressed = Compression.GZipHelper.Decompress(data); + OnDataAvailable(decompressed); + } + catch (Exception ex) + { + if (ex.Message.Contains("GZip")) + { + //Temporarily ignore, probably switching protocol definitions... + OnDataAvailable(data); + } + else + { + throw ex; + } + } + } + else + { + OnDataAvailable(data); + } } } + catch (Exception ex) + { + OnFailed(ex); + } } private void StartPushThread() diff --git a/Software/Visual_Studio/Tango.Transport/Adapters/TcpTransportAdapter.cs b/Software/Visual_Studio/Tango.Transport/Adapters/TcpTransportAdapter.cs index f4bfb0ba8..427c335ff 100644 --- a/Software/Visual_Studio/Tango.Transport/Adapters/TcpTransportAdapter.cs +++ b/Software/Visual_Studio/Tango.Transport/Adapters/TcpTransportAdapter.cs @@ -249,7 +249,21 @@ namespace Tango.Transport.Adapters if (EnableCompression) { - data = GZipHelper.Decompress(data); + try + { + data = GZipHelper.Decompress(data); + } + catch (Exception ex) + { + if (ex.Message.Contains("GZip")) + { + //Temporarily ignore, probably switching protocol definitions... + } + else + { + throw ex; + } + } } OnDataAvailable(data); diff --git a/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs b/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs index 55d07ef37..50c4221ab 100644 --- a/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs +++ b/Software/Visual_Studio/Tango.Transport/GenericMessageSerializer.cs @@ -16,31 +16,21 @@ namespace Tango.Transport { public static class GenericMessageSerializer { - public enum GenericMessageSerializerMode - { - Json, - Bson, - Protobuf - } - - public static GenericMessageSerializerMode Mode { get; set; } - static GenericMessageSerializer() { - Mode = GenericMessageSerializerMode.Bson; ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddMissingTypes = true; ProtoBuf.Meta.RuntimeTypeModel.Default.AutoAddProtoContractTypesOnly = false; ProtoBuf.Meta.RuntimeTypeModel.Default.InferTagFromNameDefault = true; ProtoBuf.Meta.RuntimeTypeModel.Default.UseImplicitZeroDefaults = true; } - public static object Deserialize(Type type, byte[] array) + public static object Deserialize(Type type, byte[] array, GenericMessageProtocol mode) { - if (Mode == GenericMessageSerializerMode.Json) + if (mode == GenericMessageProtocol.Json) { return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(array), type); } - else if (Mode == GenericMessageSerializerMode.Bson) + else if (mode == GenericMessageProtocol.Bson) { return DeserializeFromBson(array, type); } @@ -55,32 +45,32 @@ namespace Tango.Transport } } - public static object DeserializeFromByteString(Type type, ByteString byteString) + public static object DeserializeFromByteString(Type type, ByteString byteString, GenericMessageProtocol mode) { - if (Mode == GenericMessageSerializerMode.Json) + if (mode == GenericMessageProtocol.Json) { return JsonConvert.DeserializeObject(byteString.ToStringUtf8(), type); } - else if (Mode == GenericMessageSerializerMode.Bson) + else if (mode == GenericMessageProtocol.Bson) { return DeserializeFromBson(byteString.ToByteArray(), type); } else { AutoProtobuf.Build(type); - return Deserialize(type, byteString.ToByteArray()); + return Deserialize(type, byteString.ToByteArray(), mode); } } //--------------------------------------------------------------------- - public static byte[] Serialize<T>(T message) + public static byte[] Serialize<T>(T message, GenericMessageProtocol mode) { - if (Mode == GenericMessageSerializerMode.Json) + if (mode == GenericMessageProtocol.Json) { return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)); } - else if (Mode == GenericMessageSerializerMode.Bson) + else if (mode == GenericMessageProtocol.Bson) { return SerializeToBson(message); } @@ -96,13 +86,13 @@ namespace Tango.Transport } } - public static T Deserialize<T>(byte[] array) + public static T Deserialize<T>(byte[] array, GenericMessageProtocol mode) { - if (Mode == GenericMessageSerializerMode.Json) + if (mode == GenericMessageProtocol.Json) { - return (T)Deserialize(typeof(T), array); + return (T)Deserialize(typeof(T), array, mode); } - else if (Mode == GenericMessageSerializerMode.Bson) + else if (mode == GenericMessageProtocol.Bson) { return DeserializeFromBson<T>(array); } @@ -117,33 +107,33 @@ namespace Tango.Transport } } - public static ByteString SerializeToByteString<T>(T message) + public static ByteString SerializeToByteString<T>(T message, GenericMessageProtocol mode) { - if (Mode == GenericMessageSerializerMode.Json) + if (mode == GenericMessageProtocol.Json) { - var byteString = ByteString.CopyFromUtf8(JsonConvert.SerializeObject(message)); + var byteString = ByteString.CopyFromUtf8(JsonConvert.SerializeObject(message)); return byteString; } - else if (Mode == GenericMessageSerializerMode.Bson) + else if (mode == GenericMessageProtocol.Bson) { var byteString = ByteString.CopyFrom(SerializeToBson(message)); return byteString; - } + } else { AutoProtobuf.Build<T>(); - return ByteString.CopyFrom(Serialize<T>(message)); + return ByteString.CopyFrom(Serialize<T>(message, mode)); } } - public static T DeserializeFromByteString<T>(ByteString byteString) + public static T DeserializeFromByteString<T>(ByteString byteString, GenericMessageProtocol mode) { - if (Mode == GenericMessageSerializerMode.Json) + if (mode == GenericMessageProtocol.Json) { return JsonConvert.DeserializeObject<T>(byteString.ToStringUtf8()); } - else if (Mode == GenericMessageSerializerMode.Bson) + else if (mode == GenericMessageProtocol.Bson) { return DeserializeFromBson<T>(byteString.ToByteArray()); } @@ -151,15 +141,15 @@ namespace Tango.Transport { AutoProtobuf.Build<T>(); - return Deserialize<T>(byteString.ToByteArray()); + return Deserialize<T>(byteString.ToByteArray(), mode); } } - public static T ExtractGenericRequestFromContainer<T>(MessageContainer container) where T : class + public static T ExtractGenericRequestFromContainer<T>(MessageContainer container, GenericMessageProtocol mode) where T : class { var message = MessageFactory.ExtractMessageFromContainer(container); var genericType = Type.GetType((message as GenericRequest).Type); - var innerMessage = DeserializeFromByteString(genericType, (message as GenericRequest).Data); + var innerMessage = DeserializeFromByteString(genericType, (message as GenericRequest).Data, mode); return innerMessage as T; } diff --git a/Software/Visual_Studio/Tango.Transport/ITransporter.cs b/Software/Visual_Studio/Tango.Transport/ITransporter.cs index 1b0391ff5..777b97e19 100644 --- a/Software/Visual_Studio/Tango.Transport/ITransporter.cs +++ b/Software/Visual_Studio/Tango.Transport/ITransporter.cs @@ -10,6 +10,7 @@ using Tango.Transport.Adapters; using Tango.PMR; using Tango.PMR.Common; using System.Collections.ObjectModel; +using Tango.PMR.Integration; namespace Tango.Transport { @@ -37,6 +38,11 @@ namespace Tango.Transport Exception FailedStateException { get; } /// <summary> + /// Gets or sets the generic protocol used to serialize/deserialize generic messages. + /// </summary> + GenericMessageProtocol GenericProtocol { get; set; } + + /// <summary> /// Registers a custom request handler. /// </summary> /// <typeparam name="Request">The type of the request.</typeparam> @@ -183,7 +189,7 @@ namespace Tango.Transport /// <summary> /// Occurs when a new request message has been received. /// </summary> - event EventHandler<MessageContainer> RequestReceived; + event EventHandler<RequestReceivedEventArgs> RequestReceived; /// <summary> /// Occurs when a new response message has been received. diff --git a/Software/Visual_Studio/Tango.Transport/RequestReceivedEventArgs.cs b/Software/Visual_Studio/Tango.Transport/RequestReceivedEventArgs.cs new file mode 100644 index 000000000..b7a406fd6 --- /dev/null +++ b/Software/Visual_Studio/Tango.Transport/RequestReceivedEventArgs.cs @@ -0,0 +1,25 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.PMR.Common; + +namespace Tango.Transport +{ + public class RequestReceivedEventArgs + { + public MessageContainer Container { get; set; } + public bool Handled { get; set; } + + public RequestReceivedEventArgs() + { + + } + + public RequestReceivedEventArgs(MessageContainer container) : this() + { + Container = container; + } + } +} diff --git a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj index 2521daa2f..054b4420c 100644 --- a/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj +++ b/Software/Visual_Studio/Tango.Transport/Tango.Transport.csproj @@ -128,6 +128,7 @@ <Compile Include="ITransporter.cs" /> <Compile Include="GenericMessageSerializer.cs" /> <Compile Include="RequestFailedEventArgs.cs" /> + <Compile Include="RequestReceivedEventArgs.cs" /> <Compile Include="ResponseErrorException.cs" /> <Compile Include="Routing\SimpleTransportRouter.cs" /> <Compile Include="Servers\ClientConnectedEventArgs.cs" /> @@ -188,7 +189,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> + <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> </VisualStudio> </ProjectExtensions> </Project>
\ No newline at end of file diff --git a/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs b/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs index 09acc4ea5..065b9dc41 100644 --- a/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransportAdapterBase.cs @@ -109,10 +109,15 @@ namespace Tango.Transport } } + private bool _enableCompression; /// <summary> /// Gets or sets a value indicating whether to enable compression/decompression of data. /// </summary> - public bool EnableCompression { get; set; } + public bool EnableCompression + { + get { return _enableCompression; } + set { _enableCompression = value; RaisePropertyChangedAuto(); } + } #endregion diff --git a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs index cf5eeda7f..435e66196 100644 --- a/Software/Visual_Studio/Tango.Transport/TransporterBase.cs +++ b/Software/Visual_Studio/Tango.Transport/TransporterBase.cs @@ -62,7 +62,7 @@ namespace Tango.Transport /// <summary> /// Occurs when a new request message has been received. /// </summary> - public event EventHandler<MessageContainer> RequestReceived; + public event EventHandler<RequestReceivedEventArgs> RequestReceived; /// <summary> /// Occurs when a new response message has been received. @@ -188,6 +188,16 @@ namespace Tango.Transport /// </summary> public Exception FailedStateException { get; private set; } + private GenericMessageProtocol _genericProtocol; + /// <summary> + /// Gets or sets the generic protocol used to serialize/deserialize generic messages. + /// </summary> + public GenericMessageProtocol GenericProtocol + { + get { return _genericProtocol; } + set { _genericProtocol = value; RaisePropertyChangedAuto(); } + } + #endregion #region Virtual Methods @@ -301,8 +311,10 @@ namespace Tango.Transport /// Called when a new request has been received. /// </summary> /// <param name="container">The request.</param> - protected virtual void OnRequestReceived(MessageContainer container) + protected virtual void OnRequestReceived(RequestReceivedEventArgs e) { + var container = e.Container; + if (_requestHandlers.Count > 0) { if (container.Type != MessageType.GenericRequest) @@ -311,6 +323,8 @@ namespace Tango.Transport if (handlers.Count > 0) //Handle { + e.Handled = true; + var request = MessageFactory.ExtractMessageFromContainer(container); foreach (var handler in handlers) @@ -334,7 +348,9 @@ namespace Tango.Transport if (handlers.Count > 0) { - var innerRequest = GenericMessageSerializer.DeserializeFromByteString(handlers[0].RequestType, genericRequest.Data); + e.Handled = true; + + var innerRequest = GenericMessageSerializer.DeserializeFromByteString(handlers[0].RequestType, genericRequest.Data, GenericProtocol); foreach (var handler in handlers) { @@ -351,7 +367,7 @@ namespace Tango.Transport } } - RequestReceived?.Invoke(this, container); + RequestReceived?.Invoke(this, e); } /// <summary> @@ -930,10 +946,10 @@ namespace Tango.Transport { GenericRequest genericRequest = new GenericRequest(); genericRequest.Type = request.GetType().AssemblyQualifiedName; - genericRequest.Data = GenericMessageSerializer.SerializeToByteString<Request>(request); + genericRequest.Data = GenericMessageSerializer.SerializeToByteString<Request>(request, GenericProtocol); var response = await SendRequest<GenericRequest, GenericResponse>(genericRequest, config); - var responseObject = GenericMessageSerializer.DeserializeFromByteString<Response>(response.Message.Data); + var responseObject = GenericMessageSerializer.DeserializeFromByteString<Response>(response.Message.Data, GenericProtocol); return responseObject; } @@ -949,7 +965,7 @@ namespace Tango.Transport GenericRequest genericRequest = new GenericRequest(); genericRequest.Type = request.GetType().AssemblyQualifiedName; - genericRequest.Data = GenericMessageSerializer.SerializeToByteString<Request>(request); + genericRequest.Data = GenericMessageSerializer.SerializeToByteString<Request>(request, GenericProtocol); Subject<Response> subject = new Subject<Response>(); @@ -958,7 +974,7 @@ namespace Tango.Transport try { - var responseObject = GenericMessageSerializer.DeserializeFromByteString<Response>(response.Message.Data); + var responseObject = GenericMessageSerializer.DeserializeFromByteString<Response>(response.Message.Data, GenericProtocol); subject.OnNext(responseObject); } catch (Exception ex) @@ -1194,8 +1210,7 @@ namespace Tango.Transport GenericResponse genericResponse = new GenericResponse(); genericResponse.Type = response.GetType().AssemblyQualifiedName; - genericResponse.Data = GenericMessageSerializer.SerializeToByteString<Response>(response); - + genericResponse.Data = GenericMessageSerializer.SerializeToByteString<Response>(response, GenericProtocol); await SendResponse<GenericResponse>(genericResponse, token, config); } @@ -1513,7 +1528,7 @@ namespace Tango.Transport { Type genericType = Type.GetType((messageContent as GenericResponse).Type); responseType = genericType.Name; - messageContent = GenericMessageSerializer.DeserializeFromByteString(genericType, (messageContent as GenericResponse).Data); + messageContent = GenericMessageSerializer.DeserializeFromByteString(genericType, (messageContent as GenericResponse).Data, GenericProtocol); } } catch { } @@ -1643,7 +1658,7 @@ namespace Tango.Transport try { - Task.Factory.StartNew(() => OnRequestReceived(container)); + Task.Factory.StartNew(() => OnRequestReceived(new RequestReceivedEventArgs(container))); } catch { @@ -1696,12 +1711,20 @@ namespace Tango.Transport if (_arrivedResponses.Count == 0) { retryCounter--; - var response = SendRequest<KeepAliveRequest, KeepAliveResponse>(new KeepAliveRequest(), new TransportRequestConfig() + + if (State == TransportComponentState.Connected) { - Timeout = KeepAliveTimeout, - Priority = QueuePriority.High - }).Result; - retryCounter = KeepAliveRetries; + var response = SendRequest<KeepAliveRequest, KeepAliveResponse>(new KeepAliveRequest(), new TransportRequestConfig() + { + Timeout = KeepAliveTimeout, + Priority = QueuePriority.High + }).Result; + retryCounter = KeepAliveRetries; + } + else + { + continue; + } } else { diff --git a/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs b/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs index d6431fe60..59784fa56 100644 --- a/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs +++ b/Software/Visual_Studio/Tango.WebRTC/WebRtcTransportAdapter.cs @@ -95,7 +95,7 @@ namespace Tango.WebRTC { if (!completed) { - LogManager.Log("WebRTC Active Transport Adapter is ready."); + LogManager.Log($"{ComponentName}: WebRTC Active Transport Adapter is ready."); completed = true; State = TransportComponentState.Connected; completionSource.SetResult(true); @@ -104,32 +104,32 @@ namespace Tango.WebRTC if (Mode == WebRtcTransportAdapterMode.Passive) { - LogManager.Log("WebRTC Passive Transport Adapter is ready."); + LogManager.Log($"{ComponentName}: WebRTC Passive Transport Adapter is ready."); Ready?.Invoke(this, new EventArgs()); } }; - LogManager.Log("Initializing WebRTC client..."); + LogManager.Log($"{ComponentName}: Initializing WebRTC client..."); await _client.Init(); if (Mode == WebRtcTransportAdapterMode.Active) { - LogManager.Log("Creating WebRTC offer..."); + LogManager.Log($"{ComponentName}: Creating WebRTC offer..."); var offer = await _client.CreateOffer(); - LogManager.Log("Sending WebRTC offer via signaling transporter..."); + LogManager.Log($"{ComponentName}: Sending WebRTC offer via signaling transporter..."); var response = await SignalingTransporter.SendGenericRequest<OfferRequest, OfferResponse>(new OfferRequest() { Offer = offer }, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30), }); - LogManager.Log("WebRTC offer sent and responded with an answer. Setting WebRTC answer..."); + LogManager.Log($"{ComponentName}: WebRTC offer sent and responded with an answer. Setting WebRTC answer..."); _client.SetAnswer(response.Answer); _answerReceived = true; foreach (var ice in _queuedIceCandidates.ToList()) { - LogManager.Log($"Sending existing ice candidate '{ice.Sdp}'..."); + LogManager.Log($"{ComponentName}: Sending existing ice candidate '{ice.Sdp}'..."); try { @@ -140,13 +140,13 @@ namespace Tango.WebRTC } catch (Exception ex) { - LogManager.Log(ex, "Error sending ice candidate."); + LogManager.Log(ex, $"{ComponentName}: Error sending ice candidate."); } } } else { - LogManager.Log("Waiting for offer..."); + LogManager.Log($"{ComponentName}: Waiting for offer..."); State = TransportComponentState.Connected; if (!completed) @@ -195,8 +195,22 @@ namespace Tango.WebRTC { if (EnableCompression) { - var decompressed = GZipHelper.Decompress(e.Data); - OnDataAvailable(decompressed); + try + { + var decompressed = GZipHelper.Decompress(e.Data); + OnDataAvailable(decompressed); + } + catch (Exception ex) + { + if (ex.Message.Contains("GZip")) + { + //Temporarily ignore, probably switching protocol definitions... + } + else + { + //Do nothing... ? + } + } } else { @@ -208,26 +222,33 @@ namespace Tango.WebRTC { if (Mode == WebRtcTransportAdapterMode.Passive) { - var answer = await _client.CreateAnswer(request.Offer); - await SignalingTransporter.SendGenericResponse(new OfferResponse() { Answer = answer }, token); - _answerReceived = true; - - foreach (var ice in _queuedIceCandidates.ToList()) + try { - LogManager.Log($"Sending existing ice candidate '{ice.Sdp}'..."); + var answer = await _client.CreateAnswer(request.Offer); + await SignalingTransporter.SendGenericResponse(new OfferResponse() { Answer = answer }, token); + _answerReceived = true; - try + foreach (var ice in _queuedIceCandidates.ToList()) { - await SignalingTransporter.SendGenericRequest<IceCandidateRequest, IceCandidateResponse>(new IceCandidateRequest() { IceCandidate = ice }, new TransportRequestConfig() + LogManager.Log($"{ComponentName}: Sending existing ice candidate '{ice.Sdp}'..."); + + try { - Timeout = TimeSpan.FromSeconds(30), - }); - } - catch (Exception ex) - { - LogManager.Log(ex, "Error sending ice candidate to remote peer."); + await SignalingTransporter.SendGenericRequest<IceCandidateRequest, IceCandidateResponse>(new IceCandidateRequest() { IceCandidate = ice }, new TransportRequestConfig() + { + Timeout = TimeSpan.FromSeconds(30), + }); + } + catch (Exception ex) + { + LogManager.Log(ex, $"{ComponentName}: Error sending ice candidate to remote peer."); + } } } + catch (Exception ex) + { + LogManager.Log(ex, $"{ComponentName}: Error occurred while trying to return WebRTC answer."); + } } } @@ -237,7 +258,7 @@ namespace Tango.WebRTC { if (_answerReceived) { - LogManager.Log("New WebRTC candidate available. Sending ice to remote peer..."); + LogManager.Log($"{ComponentName}: New WebRTC candidate available. Sending ice to remote peer..."); await SignalingTransporter.SendGenericRequest<IceCandidateRequest, IceCandidateResponse>(new IceCandidateRequest() { IceCandidate = e.IceCandidate }, new TransportRequestConfig() { @@ -248,11 +269,11 @@ namespace Tango.WebRTC { if (Mode == WebRtcTransportAdapterMode.Active) { - LogManager.Log("New WebRTC candidate available. Will be sent after an answer is received..."); + LogManager.Log($"{ComponentName}: New WebRTC candidate available. Will be sent after an answer is received..."); } else { - LogManager.Log("New WebRTC candidate available. Will be sent after an offer is received..."); + LogManager.Log($"{ComponentName}: New WebRTC candidate available. Will be sent after an offer is received..."); } _queuedIceCandidates.Add(e.IceCandidate); @@ -260,7 +281,7 @@ namespace Tango.WebRTC } catch (Exception ex) { - LogManager.Log(ex, "Error sending ice candidate to remote peer."); + LogManager.Log(ex, $"{ComponentName}: Error sending ice candidate to remote peer."); } } @@ -271,7 +292,7 @@ namespace Tango.WebRTC LogManager.Log($"{ComponentName}: Ice candidate request received from the remote peer."); await SignalingTransporter.SendGenericResponse(new IceCandidateResponse() { }, token); - LogManager.Log($"Adding ice candidate '{request.IceCandidate.Sdp}'..."); + LogManager.Log($"{ComponentName}: Adding ice candidate '{request.IceCandidate.Sdp}'..."); _client.AddIceCandidate(request.IceCandidate); LogManager.Log($"{ComponentName}: Ice candidate added."); } @@ -296,7 +317,7 @@ namespace Tango.WebRTC { if (_client != null) { - LogManager.Log("Disposing WebRTC client..."); + LogManager.Log($"{ComponentName}: Disposing WebRTC client..."); _client.NewIceCandidate -= WebRtc_NewIceCandidate; _client.Disconnected -= WebRtc_Disconnected; @@ -308,11 +329,11 @@ namespace Tango.WebRTC _client = null; SignalingTransporter.UnregisterRequestHandler<IceCandidateRequest>(OnIceCandidateRequestReceived); SignalingTransporter.UnregisterRequestHandler<OfferRequest>(OnOfferRequestReceived); - LogManager.Log("WebRTC client disposed."); + LogManager.Log($"{ComponentName}: WebRTC client disposed."); } catch (Exception ex) { - LogManager.Log(ex, "Error disposing WebRTC client."); + LogManager.Log(ex, $"{ComponentName}: Error disposing WebRTC client."); } } |
