Linux screen cast working. Mouse and keyboard input is still remaining.

This commit is contained in:
Jared Goodwin 2019-03-28 14:46:39 -07:00
parent d37b75f7af
commit 324e5877d6
7 changed files with 17 additions and 10 deletions

View File

@ -10,6 +10,7 @@ using System.Linq;
using System.Runtime.InteropServices;
using System.ServiceProcess;
using System.Threading.Tasks;
using System.Diagnostics;
namespace Remotely_Agent
{

View File

@ -288,7 +288,8 @@ namespace Remotely_Agent.Services
{
var users = OSUtils.StartProcessWithResults("users", "");
var username = users?.Split()?.FirstOrDefault()?.Trim();
Process.Start("sudo", $"-u {username} {rcBinaryPath} -mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -desktop default & disown");
var casterProc = Process.Start("sudo", $"-u {username} {rcBinaryPath} -mode Unattended -requester {requesterID} -serviceid {serviceID} -host {Utilities.GetConnectionInfo().Host} -desktop default & disown");
casterProc.WaitForExit();
}
}
catch (Exception ex)
@ -333,7 +334,8 @@ namespace Remotely_Agent.Services
var users = OSUtils.StartProcessWithResults("users", "");
var username = users?.Split()?.FirstOrDefault()?.Trim();
Process.Start("sudo", $"-u {username} {rcBinaryPath} -mode Unattended -requester {requesterID} -serviceid {serviceID} -hostname {Utilities.GetConnectionInfo().Host} -desktop default & disown");
var casterProc = Process.Start("sudo", $"-u {username} {rcBinaryPath} -mode Unattended -requester {requesterID} -serviceid {serviceID} -hostname {Utilities.GetConnectionInfo().Host} -relaunch true -desktop default -viewers {String.Join(",", viewerIDs)} & disown");
casterProc.WaitForExit();
}
}
catch (Exception ex)

View File

@ -4,6 +4,7 @@ using Remotely_ScreenCast.Linux.X11Interop;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.Text;
namespace Remotely_ScreenCast.Linux.Capture
@ -21,7 +22,7 @@ namespace Remotely_ScreenCast.Linux.Capture
public IntPtr Display { get; private set; }
public Bitmap PreviousFrame { get; set; }
public EventHandler<Rectangle> ScreenChanged { get; set; }
public int SelectedScreen { get; private set; }
public int SelectedScreen { get; private set; } = -1;
private Graphics Graphic { get; set; }
private object ScreenLock { get; } = new object();
public void Capture()
@ -76,7 +77,11 @@ namespace Remotely_ScreenCast.Linux.Capture
public void Init()
{
Display = Xlib.XOpenDisplay(null);
SelectedScreen = Xlib.XDefaultScreen(Display);
var defaultScreen = Xlib.XDefaultScreen(Display);
SetSelectedScreen(defaultScreen);
CurrentFrame = new Bitmap(CurrentScreenBounds.Width, CurrentScreenBounds.Height, PixelFormat.Format32bppArgb);
PreviousFrame = new Bitmap(CurrentScreenBounds.Width, CurrentScreenBounds.Height, PixelFormat.Format32bppArgb);
Graphic = Graphics.FromImage(CurrentFrame);
}
public void SetSelectedScreen(int screenNumber)
@ -95,8 +100,8 @@ namespace Remotely_ScreenCast.Linux.Capture
{
SelectedScreen = 0;
}
var width = Xlib.XWidthOfScreen(Xlib.XScreenOfDisplay(Display, screenNumber));
var height = Xlib.XWidthOfScreen(Xlib.XScreenOfDisplay(Display, screenNumber));
var width = Xlib.XDisplayWidth(Display, SelectedScreen);
var height = Xlib.XDisplayHeight(Display, SelectedScreen);
CurrentScreenBounds = new Rectangle(0, 0, width, height);
CaptureFullscreen = true;
Init();

View File

@ -19,6 +19,7 @@ namespace Remotely_ScreenCast.Linux
{
try
{
ScreenCastInitiated(null, new Tuple<string, string>("asdf", "asdf"));
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
Conductor = new Conductor();
Conductor.ProcessArgs(args);
@ -30,11 +31,9 @@ namespace Remotely_ScreenCast.Linux
Conductor.OutgoingMessages.SendDeviceInfo(Conductor.ServiceID, Environment.MachineName).Wait();
Conductor.OutgoingMessages.NotifyRequesterUnattendedReady(Conductor.RequesterID).Wait();
Conductor.StartWaitForViewerTimer();
while (true)
{
System.Threading.Thread.Sleep(100);
Console.Read();
}
}
catch (Exception ex)

View File

@ -97,7 +97,6 @@ namespace Remotely_ScreenCast.Win
if (Conductor?.OutgoingMessages != null)
{
await Conductor.OutgoingMessages.SendCursorChange(cursor, Conductor.Viewers.Keys.ToList());
}
}

View File

@ -1 +1 @@
2019.03.28.1025
2019.03.28.1441

View File

@ -162,6 +162,7 @@ namespace Remotely_Server.Services
Message = $"Remote control session requested by {requesterName}. " +
$"Connection ID: {Context.ConnectionId}. User ID: {Context.UserIdentifier}. " +
$"Screen Caster ID: {screenCasterID}." +
$"Mode: {((RemoteControlMode)remoteControlMode).ToString()}" +
$"Login ID (if logged in): {Context?.User?.Identity?.Name}. " +
$"Requester IP Address: " + Context?.GetHttpContext()?.Connection?.RemoteIpAddress?.ToString()
});