aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs')
-rw-r--r--Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs45
1 files changed, 37 insertions, 8 deletions
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 b13b797e9..6f25e1774 100644
--- a/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs
+++ b/Software/Visual_Studio/FSE/Tango.FSE.UI/FileSystem/DefaultFileSystemProvider.cs
@@ -25,7 +25,8 @@ namespace Tango.FSE.UI.FileSystem
private BasicTransporter _webRtcTransporter;
private const string WEB_RTC_CHANNEL_NAME = "FileSystemChannel";
private const long MAX_CHUNK_SIZE = 1024 * 10;
- private const long MAX_CHUNK_SIZE_WEB_RTC = 1024 * 15;
+ private const long MAX_CHUNK_SIZE_WEB_RTC = 1024 * 50;
+ private const int WEB_RTC_MAX_RETRIES = 8;
private List<FileSystemHandler> _activeHandlers;
private bool _enableWebRTC;
@@ -52,7 +53,7 @@ namespace Tango.FSE.UI.FileSystem
_machineProvider.MachineDisconnected += _machineProvider_MachineDisconnected;
}
- private void _machineProvider_MachineDisconnected(object sender, MachineDisconnectedEventArgs e)
+ private async void _machineProvider_MachineDisconnected(object sender, MachineDisconnectedEventArgs e)
{
IsWebRtcAvailable = false;
@@ -69,6 +70,19 @@ namespace Tango.FSE.UI.FileSystem
}
_activeHandlers.Clear();
+
+ if (_webRtcTransporter != null)
+ {
+ try
+ {
+ LogManager.Log("Machine disconnected. Disconnecting FileSystem WebRTC Transporter...");
+ await _webRtcTransporter.Disconnect();
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error while disconnecting FileSystem WebRTC Transporter.");
+ }
+ }
}
private async void _machineProvider_MachineConnected(object sender, MachineConnectedEventArgs e)
@@ -100,8 +114,6 @@ namespace Tango.FSE.UI.FileSystem
catch (Exception ex)
{
IsWebRtcAvailable = false;
- EnableWebRTC = false;
-
LogManager.Log(ex, "Error initializing FileSystem via WebRTC.");
}
}
@@ -226,6 +238,7 @@ namespace Tango.FSE.UI.FileSystem
long position = 0;
bool webRtcFailed = false;
+ int webRtcRetries = WEB_RTC_MAX_RETRIES;
var tempFile = TemporaryManager.CreateFile();
@@ -252,18 +265,34 @@ namespace Tango.FSE.UI.FileSystem
try
{
request.MaxChunkSize = MAX_CHUNK_SIZE_WEB_RTC;
- response = await _webRtcTransporter.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30), Priority = QueuePriority.Low });
+ response = await _webRtcTransporter.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig()
+ {
+ Timeout = TimeSpan.FromSeconds(2),
+ Priority = QueuePriority.Low
+ });
+
+ webRtcRetries = WEB_RTC_MAX_RETRIES;
}
catch (Exception ex)
{
- webRtcFailed = true;
- LogManager.Log(ex, "WebRTC chunk download failed. Falling back to standard download...");
+ webRtcRetries--;
+
+ if (webRtcRetries == 0)
+ {
+ webRtcFailed = true;
+ LogManager.Log(ex, "WebRTC chunk download failed. Falling back to standard download...");
+ }
+
continue;
}
}
else
{
- response = await _machineProvider.MachineOperator.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig() { Timeout = TimeSpan.FromSeconds(30), Priority = QueuePriority.Low });
+ response = await _machineProvider.MachineOperator.SendGenericRequest<ChunkDownloadRequest, ChunkDownloadResponse>(request, new TransportRequestConfig()
+ {
+ Timeout = TimeSpan.FromSeconds(30),
+ Priority = QueuePriority.Low
+ });
}
using (FileStream fs = new FileStream(tempFile, FileMode.Append))