diff --git a/Agent/Services/DeviceSocket.cs b/Agent/Services/DeviceSocket.cs index e28f32edd..62be23ad1 100644 --- a/Agent/Services/DeviceSocket.cs +++ b/Agent/Services/DeviceSocket.cs @@ -58,7 +58,7 @@ public async Task Connect() var device = await DeviceInformation.Create(ConnectionInfo.DeviceID, ConnectionInfo.OrganizationID); - var result = await HubConnection.SendAsync("DeviceCameOnline", device); + var result = await HubConnection.InvokeAsync("DeviceCameOnline", device); if (!result) { diff --git a/Tests/CaptureTests.cs b/Tests/CaptureTests.cs new file mode 100644 index 000000000..950d36a69 --- /dev/null +++ b/Tests/CaptureTests.cs @@ -0,0 +1,54 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Remotely.ScreenCast.Core.Utilities; +using Remotely.ScreenCast.Win.Services; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Drawing.Imaging; +using System.IO; +using System.Text; +using System.Threading.Tasks; + +namespace Remotely.Tests +{ + [TestClass] + public class CaptureTests + { + [TestMethod] + [Ignore("Debug only.")] + public async Task Capture() + { + var capturer = new ScreenCapturerWin(); + capturer.GetNextFrame(); + Process.Start("msg", "* test"); + await Task.Delay(500); + capturer.GetNextFrame(); + var diffArea = ImageUtils.GetDiffArea(capturer.CurrentFrame, capturer.PreviousFrame, false); + if (diffArea.IsEmpty) + { + return; + } + using (var newImage = capturer.CurrentFrame.Clone(diffArea, PixelFormat.Format32bppArgb)) + { + if (capturer.CaptureFullscreen) + { + capturer.CaptureFullscreen = false; + } + + newImage.Save(Path.Combine(Path.GetTempPath(), "!ImageDiff.jpg"), ImageFormat.Jpeg); + capturer.CurrentFrame.Save(Path.Combine(Path.GetTempPath(), "!Current.jpg"), ImageFormat.Jpeg); + capturer.PreviousFrame.Save(Path.Combine(Path.GetTempPath(), "!Previous.jpg"), ImageFormat.Jpeg); + } + } + + + private double MeasureCommand(Action command) + { + var stopwatch = Stopwatch.StartNew(); + command.Invoke(); + stopwatch.Stop(); + Console.WriteLine($"Command time: {stopwatch.Elapsed.TotalMilliseconds}"); + return stopwatch.Elapsed.TotalMilliseconds; + } + } +} diff --git a/Tests/Tests.csproj b/Tests/Tests.csproj index bcf74192a..e1e3c9c6a 100644 --- a/Tests/Tests.csproj +++ b/Tests/Tests.csproj @@ -26,6 +26,7 @@ +