Skip to content

Commit

Permalink
Merge branch 'master' into desktop_wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Apr 22, 2020
2 parents 5087a46 + 9e371dc commit a21ff67
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 162 deletions.
8 changes: 8 additions & 0 deletions Desktop.Win/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,14 @@ private void ScreenCastRequested(object sender, ScreenCastRequest screenCastRequ
Services.GetRequiredService<IScreenCaster>().BeginScreenCasting(screenCastRequest);
});
}
else
{
// Run on another thread so it doesn't tie up the UI thread.
Task.Run(async () =>
{
await CasterSocket.SendConnectionRequestDenied(screenCastRequest.ViewerID);
});
}
});
}
private void SessionIDChanged(object sender, string sessionID)
Expand Down
10 changes: 7 additions & 3 deletions ScreenCast.Core/Communication/CasterSocket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,11 @@ public CasterSocket(

public HubConnection Connection { get; private set; }
public bool IsConnected => Connection?.State == HubConnectionState.Connected;
private IScreenCaster ScreenCaster { get; }
private IFileTransferService FileDownloadService { get; }
private IAudioCapturer AudioCapturer { get; }

private IClipboardService ClipboardService { get; }
private IFileTransferService FileDownloadService { get; }
private IKeyboardMouseInput KeyboardMouseInput { get; }
private IScreenCaster ScreenCaster { get; }
public async Task Connect(string host)
{
if (Connection != null)
Expand Down Expand Up @@ -89,6 +88,11 @@ public async Task SendConnectionFailedToViewers(List<string> viewerIDs)
await Connection.SendAsync("SendConnectionFailedToViewers", viewerIDs);
}

public async Task SendConnectionRequestDenied(string viewerID)
{
await Connection.SendAsync("SendConnectionRequestDenied", viewerID);
}

public async Task SendCtrlAltDel()
{
await Connection.SendAsync("CtrlAltDel");
Expand Down
24 changes: 11 additions & 13 deletions Server/Services/RCBrowserSocketHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ public Task SelectScreen(string displayName)
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("SelectScreen", displayName, Context.ConnectionId);
}

public Task SendAutoQualityAdjust(bool isOn)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("AutoQualityAdjust", isOn, Context.ConnectionId);
}

public Task SendClipboardTransfer(string transferText, bool typeText)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("ClipboardTransfer", transferText, typeText, Context.ConnectionId);
Expand All @@ -143,15 +148,18 @@ public Task SendFrameReceived(int bytesReceived)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("FrameReceived", bytesReceived, Context.ConnectionId);
}
public Task SendIceCandidateToAgent(string candidate, int sdpMlineIndex, string sdpMid)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("ReceiveIceCandidate", candidate, sdpMlineIndex, sdpMid, Context.ConnectionId);
}

public Task SendQualityChange(int qualityLevel)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("QualityChange", qualityLevel, Context.ConnectionId);
}

public Task SendAutoQualityAdjust(bool isOn)
public Task SendRtcAnswerToAgent(string sdp)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("AutoQualityAdjust", isOn, Context.ConnectionId);
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("ReceiveRtcAnswer", sdp, Context.ConnectionId);
}

public async Task<Task> SendScreenCastRequestToDevice(string screenCasterID, string requesterName, int remoteControlMode)
Expand Down Expand Up @@ -260,15 +268,5 @@ public Task TouchUp()
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("TouchUp", Context.ConnectionId);
}

public Task SendIceCandidateToAgent(string candidate, int sdpMlineIndex, string sdpMid)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("ReceiveIceCandidate", candidate, sdpMlineIndex, sdpMid, Context.ConnectionId);
}

public Task SendRtcAnswerToAgent(string sdp)
{
return RCDeviceHub.Clients.Client(ScreenCasterID).SendAsync("ReceiveRtcAnswer", sdp, Context.ConnectionId);
}
}
}
25 changes: 14 additions & 11 deletions Server/Services/RCDeviceSocketHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -162,36 +162,39 @@ public Task SendConnectionFailedToViewers(List<string> viewerIDs)
{
return RCBrowserHub.Clients.Clients(viewerIDs).SendAsync("ConnectionFailed");
}

public Task SendCursorChange(CursorInfo cursor, string viewerID)
public Task SendConnectionRequestDenied(string viewerID)
{
return RCBrowserHub.Clients.Client(viewerID).SendAsync("CursorChange", cursor);
return RCBrowserHub.Clients.Client(viewerID).SendAsync("ConnectionRequestDenied");
}

public Task SendMachineName(string machineName, string viewerID)
public Task SendCursorChange(CursorInfo cursor, string viewerID)
{
return RCBrowserHub.Clients.Client(viewerID).SendAsync("ReceiveMachineName", machineName);
return RCBrowserHub.Clients.Client(viewerID).SendAsync("CursorChange", cursor);
}

public Task SendRtcOfferToBrowser(string sdp, string viewerID)
public Task SendIceCandidateToBrowser(string candidate, int sdpMlineIndex, string sdpMid, string viewerID)
{
if (AppConfig.UseWebRtc)
{
return RCBrowserHub.Clients.Client(viewerID).SendAsync("ReceiveRtcOffer", sdp);
return RCBrowserHub.Clients.Client(viewerID).SendAsync("ReceiveIceCandidate", candidate, sdpMlineIndex, sdpMid);
}

return Task.CompletedTask;
}
public Task SendIceCandidateToBrowser(string candidate, int sdpMlineIndex, string sdpMid, string viewerID)

public Task SendMachineName(string machineName, string viewerID)
{
return RCBrowserHub.Clients.Client(viewerID).SendAsync("ReceiveMachineName", machineName);
}

public Task SendRtcOfferToBrowser(string sdp, string viewerID)
{
if (AppConfig.UseWebRtc)
{
return RCBrowserHub.Clients.Client(viewerID).SendAsync("ReceiveIceCandidate", candidate, sdpMlineIndex, sdpMid);
return RCBrowserHub.Clients.Client(viewerID).SendAsync("ReceiveRtcOffer", sdp);
}

return Task.CompletedTask;
}

public Task SendScreenCapture(byte[] captureBytes, string rcBrowserHubConnectionID, int left, int top, int width, int height, long imageQuality)
{
if (AppConfig.RecordRemoteControlSessions)
Expand Down
2 changes: 1 addition & 1 deletion Server/wwwroot/scripts/RemoteControl/MessageSender.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Server/wwwroot/scripts/RemoteControl/MessageSender.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a21ff67

Please sign in to comment.