aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
diff options
context:
space:
mode:
authorRoy Ben-Shabat <Roy@Twine-s.com>2020-03-18 04:40:49 +0200
committerRoy Ben-Shabat <Roy@Twine-s.com>2020-03-18 04:40:49 +0200
commitc53d907d27de01a9cc6f1bbbb8819e879d7dbe44 (patch)
tree5dace8dbda804f275c27c3ecae4facd9f618dd81 /Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
parentab9f5994949565dd664c1a33fb4e0a105a57eec6 (diff)
downloadTango-c53d907d27de01a9cc6f1bbbb8819e879d7dbe44.tar.gz
Tango-c53d907d27de01a9cc6f1bbbb8819e879d7dbe44.zip
Added PPC support for mouse gestures via WebRTC.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs32
1 files changed, 30 insertions, 2 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
index f669e267e..3bcb2adbd 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/RemoteDesktop/DefaultRemoteDesktopService.cs
@@ -1,4 +1,5 @@
-using System;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
@@ -41,6 +42,7 @@ namespace Tango.PPC.Common.RemoteDesktop
private RasterScreenCaptureEngine _engine;
private PPCSettings _settings;
private List<RemoteDesktopClient> _clients;
+ private JsonSerializerSettings _jsonSettings;
private bool _isStarted;
@@ -60,6 +62,11 @@ namespace Tango.PPC.Common.RemoteDesktop
public DefaultRemoteDesktopService(IPPCApplicationManager applicationManager, IPPCExternalBridgeService externalBridge)
{
+ _jsonSettings = new JsonSerializerSettings()
+ {
+ TypeNameHandling = TypeNameHandling.All
+ };
+
_settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
applicationManager.ApplicationReady += ApplicationManager_ApplicationReady;
@@ -125,6 +132,7 @@ namespace Tango.PPC.Common.RemoteDesktop
newClient.Receiver = receiver;
newClient.Token = token;
newClient.WebRtcClient = new WebRtcClient();
+ newClient.WebRtcClient.TextMessageReceived += WebRtcClient_TextMessageReceived;
_clients.Add(newClient);
await receiver.SendGenericResponse(new StartRemoteDesktopSessionResponse()
@@ -274,7 +282,10 @@ namespace Tango.PPC.Common.RemoteDesktop
MouseController.MouseEvent(MouseEventFlags.LeftUp);
}
- await receiver.SendGenericResponse(new MouseStateResponse(), token);
+ if (receiver != null)
+ {
+ await receiver.SendGenericResponse(new MouseStateResponse(), token);
+ }
}
[ExternalBridgeRequestHandlerMethod(typeof(KeyboardStateRequest))]
@@ -398,6 +409,23 @@ namespace Tango.PPC.Common.RemoteDesktop
e.Frame.Dispose();
}
+ private void WebRtcClient_TextMessageReceived(object sender, DataMessageReceivedEventArgs<string> e)
+ {
+ try
+ {
+ var request = JsonConvert.DeserializeObject(e.Data, _jsonSettings);
+
+ if (request.GetType() == typeof(MouseStateRequest))
+ {
+ OnMouseStateRequestReceived(request as MouseStateRequest, null, null);
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error deserializing incoming from message on the WebRTC data Channel.");
+ }
+ }
+
public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
{
var client = _clients.SingleOrDefault(x => x.Receiver == receiver);