From a352582311bb96fa4979edd219dce30157f4a735 Mon Sep 17 00:00:00 2001 From: Jared Goodwin Date: Fri, 29 May 2020 17:41:29 -0700 Subject: [PATCH] Add SignalR event handler for file transfer (for when WebRTC fails). --- .../Services/FileTransferService.cs | 5 - Server/Services/RCBrowserHub.cs | 10 +- .../RemoteControl/MessageSender.js.map | 2 +- .../scripts/RemoteControl/MessageSender.ts | 290 +++++++++--------- 4 files changed, 155 insertions(+), 152 deletions(-) diff --git a/ScreenCast.Core/Services/FileTransferService.cs b/ScreenCast.Core/Services/FileTransferService.cs index 9a4c45f9..4b8b973f 100644 --- a/ScreenCast.Core/Services/FileTransferService.cs +++ b/ScreenCast.Core/Services/FileTransferService.cs @@ -88,10 +88,6 @@ namespace Remotely.ScreenCast.Core.Services { fileStream.Close(); partialTransfers.Remove(messageId, out _); - if (EnvironmentHelper.IsWindows) - { - Process.Start("explorer.exe", baseDir); - } } } catch (Exception ex) @@ -101,7 +97,6 @@ namespace Remotely.ScreenCast.Core.Services finally { writeLock.Release(); - if (endOfFile) { await Task.Run(ShowTransferComplete); diff --git a/Server/Services/RCBrowserHub.cs b/Server/Services/RCBrowserHub.cs index b8eaef9e..7ecfca35 100644 --- a/Server/Services/RCBrowserHub.cs +++ b/Server/Services/RCBrowserHub.cs @@ -183,7 +183,15 @@ namespace Remotely.Server.Services { return RCDeviceHubContext.Clients.Client(ScreenCasterID).SendAsync("ClipboardTransfer", transferText, typeText, Context.ConnectionId); } - + public async Task SendFile(byte[] buffer, string fileName, string messageId, bool endOfFile, bool startOfFile) + { + await RCDeviceHubContext.Clients.Client(ScreenCasterID).SendAsync("ReceiveFile", + buffer, + fileName, + messageId, + endOfFile, + startOfFile); + } public Task SendFrameReceived(int bytesReceived) { return RCDeviceHubContext.Clients.Client(ScreenCasterID).SendAsync("FrameReceived", bytesReceived, Context.ConnectionId); diff --git a/Server/wwwroot/scripts/RemoteControl/MessageSender.js.map b/Server/wwwroot/scripts/RemoteControl/MessageSender.js.map index eb5ec4b8..1bc526ee 100644 --- a/Server/wwwroot/scripts/RemoteControl/MessageSender.js.map +++ b/Server/wwwroot/scripts/RemoteControl/MessageSender.js.map @@ -1 +1 @@ -{"version":3,"file":"MessageSender.js","sourceRoot":"","sources":["MessageSender.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EACH,aAAa,EACb,UAAU,EACV,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,MAAM,EACN,oBAAoB,EACpB,cAAc,EACd,mBAAmB,EACnB,oBAAoB,EACpB,OAAO,EACP,kBAAkB,EAElB,UAAU,EACb,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE1D,MAAM,OAAO,aAAa;IACtB,kBAAkB;QACd,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,kBAAkB,EAAE,CAAC,EACtE,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAC3D,CAAC;IACD,oBAAoB,CAAC,SAAiB;QAClC,MAAM,CAAC,eAAe,CAAC,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC3D,CAAC;IACD,gBAAgB,CAAC,WAAmB;QAChC,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,eAAe,CAAC,WAAW,CAAC,CAAC,EAC9E,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,CAAC;IACpE,CAAC;IACD,a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AC,eAAe,CAAC,oBAAoB,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrE,CAAC;IACD,qBAAqB,CAAC,IAAY,EAAE,QAAiB;QACjD,IAAI,CAAC,WAAW,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,EACtF,GAAG,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,qBAAqB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;IAC5E,CAAC;IAEO,iBAAiB;QACrB,OAAO,MAAM,CAAC,UAAU,CAAC,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,IAAI,MAAM,CAAC;IAC/F,CAAC;IAEO,WAAW,CAAC,OAAmB,EAAE,aAAyB;QAC9D,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,UAAU,IAAI,MAAM,EAAE;YACrF,OAAO,EAAE,CAAC;SACb;aACI,IAAI,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,iBAAiB,EAAE;YAC1D,aAAa,EAAE,CAAC;SACnB;IACL,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,OAA2B,EAAE,aAAiC;QACzF,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE;YAC1B,MAAM,OAAO,EAAE,CAAC;SACnB;aACI;YACD,MAAM,aAAa,EAAE,CAAC;SACzB;IACL,CAAC;CAGJ"} \ No newline at end of file diff --git a/Server/wwwroot/scripts/RemoteControl/MessageSender.ts b/Server/wwwroot/scripts/RemoteControl/MessageSender.ts index 44688ca8..1882eb78 100644 --- a/Server/wwwroot/scripts/RemoteControl/MessageSender.ts +++ b/Server/wwwroot/scripts/RemoteControl/MessageSender.ts @@ -1,147 +1,147 @@ -import { MainRc } from "./Main.js"; -import { - CtrlAltDelDto, - KeyDownDto, - KeyPressDto, - KeyUpDto, - MouseDownDto, - MouseMoveDto, - MouseUpDto, - MouseWheelDto, - QualityChangeDto, - SelectScreenDto, - TapDto, - AutoQualityAdjustDto, - ToggleAudioDto, - ToggleBlockInputDto, - ClipboardTransferDto, - FileDto, - WindowsSessionsDto, +import { MainRc } from "./Main.js"; +import { + CtrlAltDelDto, + KeyDownDto, + KeyPressDto, + KeyUpDto, + MouseDownDto, + MouseMoveDto, + MouseUpDto, + MouseWheelDto, + QualityChangeDto, + SelectScreenDto, + TapDto, + AutoQualityAdjustDto, + ToggleAudioDto, + ToggleBlockInputDto, + ClipboardTransferDto, + FileDto, + WindowsSessionsDto, GenericDto -} from "./RtcDtos.js"; -import { CreateGUID, When } from "../Utilities.js"; -import { FileTransferProgress } from "./UI.js"; -import { BinaryDtoType } from "../Enums/BinaryDtoType.js"; - -export class MessageSender { - GetWindowsSessions() { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new WindowsSessionsDto()), - () => MainRc.RCHubConnection.GetWindowsSessions()); - } - ChangeWindowsSession(sessionId: number) { - MainRc.RCHubConnection.ChangeWindowsSession(sessionId); - } - SendSelectScreen(displayName: string) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new SelectScreenDto(displayName)), - () => MainRc.RCHubConnection.SendSelectScreen(displayName)); - } - SendMouseMove(percentX: number, percentY: number) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseMoveDto(percentX, percentY)), - () => MainRc.RCHubConnection.SendMouseMove(percentX, percentY)); - } - SendMouseDown(button: number, percentX: number, percentY: number) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseDownDto(button, percentX, percentY)), - () => MainRc.RCHubConnection.SendMouseDown(button, percentX, percentY)); - } - SendMouseUp(button: number, percentX: number, percentY: number) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseUpDto(button, percentX, percentY)), - () => MainRc.RCHubConnection.SendMouseUp(button, percentX, percentY)); - } - SendTap(percentX: number, percentY: number) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new TapDto(percentX, percentY)), - () => MainRc.RCHubConnection.SendTap(percentX, percentY)); - } - SendMouseWheel(deltaX: number, deltaY: number) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseWheelDto(deltaX, deltaY)), - () => MainRc.RCHubConnection.SendMouseWheel(deltaX, deltaY)); - } - SendKeyDown(key: string) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new KeyDownDto(key)), - () => MainRc.RCHubConnection.SendKeyDown(key)); - } - SendKeyUp(key: string) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new KeyUpDto(key)), - () => MainRc.RCHubConnection.SendKeyUp(key)); - } - SendKeyPress(key: string) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new KeyPressDto(key)), - () => MainRc.RCHubConnection.SendKeyPress(key)); - } - SendSetKeyStatesUp() { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new GenericDto(BinaryDtoType.SetKeyStatesUp)), - () => MainRc.RCHubConnection.SendSetKeyStatesUp()); - } - SendCtrlAltDel() { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new CtrlAltDelDto()), - () => MainRc.RCHubConnection.SendCtrlAltDel()); - } - - async SendFile(buffer: Uint8Array, fileName: string) { - var messageId = CreateGUID(); - - this.SendToAgent(() => MainRc.RtcSession.SendDto(new FileDto(null, fileName, messageId, false, true)), - () => MainRc.RCHubConnection.SendFile(null, fileName, messageId, false, true)); - - for (var i = 0; i < buffer.byteLength; i += 50_000) { - - await this.SendToAgentAsync(async () => { - MainRc.RtcSession.SendDto(new FileDto(buffer.slice(i, i + 50_000), fileName, messageId, false, false)); - await When(() => MainRc.RtcSession.DataChannel.bufferedAmount == 0, 10); - }, async () => { - await MainRc.RCHubConnection.SendFile(buffer.slice(i, i + 50_000), fileName, messageId, false, false); - }); - - if (i > 0) { - FileTransferProgress.value = i / buffer.byteLength; - } - } - - this.SendToAgent(() => MainRc.RtcSession.SendDto(new FileDto(null, fileName, messageId, true, false)), - () => MainRc.RCHubConnection.SendFile(null, fileName, messageId, true, false)); - } - - SendQualityChange(qualityLevel: number) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new QualityChangeDto(qualityLevel)), - () => MainRc.RCHubConnection.SendQualityChange(qualityLevel)); - } - SendAutoQualityAdjust(isOn: boolean) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new AutoQualityAdjustDto(isOn)), - () => MainRc.RCHubConnection.SendAutoQualityAdjust(isOn)); - } - SendToggleAudio(toggleOn: boolean) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new ToggleAudioDto(toggleOn)), - () => MainRc.RCHubConnection.SendToggleAudio(toggleOn)); - }; - SendToggleBlockInput(toggleOn: boolean) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new ToggleBlockInputDto(toggleOn)), - () => MainRc.RCHubConnection.SendToggleBlockInput(toggleOn)); - } - SendClipboardTransfer(text: string, typeText: boolean) { - this.SendToAgent(() => MainRc.RtcSession.SendDto(new ClipboardTransferDto(text, typeText)), - () => MainRc.RCHubConnection.SendClipboardTransfer(text, typeText)); - } - - private IsWebRtcAvailable() { - return MainRc.RtcSession.DataChannel && MainRc.RtcSession.DataChannel.readyState == "open"; - } - - private SendToAgent(rtcSend: () => void, websocketSend: () => void) { - if (MainRc.RtcSession.DataChannel && MainRc.RtcSession.DataChannel.readyState == "open") { - rtcSend(); - } - else if (MainRc.RCHubConnection.Connection.connectionStarted) { - websocketSend(); - } - } - - private async SendToAgentAsync(rtcSend: () => Promise, websocketSend: () => Promise) { - if (this.IsWebRtcAvailable()) { - await rtcSend(); - } - else { - await websocketSend(); - } - } - - +} from "./RtcDtos.js"; +import { CreateGUID, When } from "../Utilities.js"; +import { FileTransferProgress } from "./UI.js"; +import { BinaryDtoType } from "../Enums/BinaryDtoType.js"; + +export class MessageSender { + GetWindowsSessions() { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new WindowsSessionsDto()), + () => MainRc.RCHubConnection.GetWindowsSessions()); + } + ChangeWindowsSession(sessionId: number) { + MainRc.RCHubConnection.ChangeWindowsSession(sessionId); + } + SendSelectScreen(displayName: string) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new SelectScreenDto(displayName)), + () => MainRc.RCHubConnection.SendSelectScreen(displayName)); + } + SendMouseMove(percentX: number, percentY: number) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseMoveDto(percentX, percentY)), + () => MainRc.RCHubConnection.SendMouseMove(percentX, percentY)); + } + SendMouseDown(button: number, percentX: number, percentY: number) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseDownDto(button, percentX, percentY)), + () => MainRc.RCHubConnection.SendMouseDown(button, percentX, percentY)); + } + SendMouseUp(button: number, percentX: number, percentY: number) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseUpDto(button, percentX, percentY)), + () => MainRc.RCHubConnection.SendMouseUp(button, percentX, percentY)); + } + SendTap(percentX: number, percentY: number) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new TapDto(percentX, percentY)), + () => MainRc.RCHubConnection.SendTap(percentX, percentY)); + } + SendMouseWheel(deltaX: number, deltaY: number) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new MouseWheelDto(deltaX, deltaY)), + () => MainRc.RCHubConnection.SendMouseWheel(deltaX, deltaY)); + } + SendKeyDown(key: string) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new KeyDownDto(key)), + () => MainRc.RCHubConnection.SendKeyDown(key)); + } + SendKeyUp(key: string) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new KeyUpDto(key)), + () => MainRc.RCHubConnection.SendKeyUp(key)); + } + SendKeyPress(key: string) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new KeyPressDto(key)), + () => MainRc.RCHubConnection.SendKeyPress(key)); + } + SendSetKeyStatesUp() { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new GenericDto(BinaryDtoType.SetKeyStatesUp)), + () => MainRc.RCHubConnection.SendSetKeyStatesUp()); + } + SendCtrlAltDel() { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new CtrlAltDelDto()), + () => MainRc.RCHubConnection.SendCtrlAltDel()); + } + + async SendFile(buffer: Uint8Array, fileName: string) { + var messageId = CreateGUID(); + + this.SendToAgent(() => MainRc.RtcSession.SendDto(new FileDto(null, fileName, messageId, false, true)), + () => MainRc.RCHubConnection.SendFile(null, fileName, messageId, false, true)); + + for (var i = 0; i < buffer.byteLength; i += 50_000) { + + await this.SendToAgentAsync(async () => { + MainRc.RtcSession.SendDto(new FileDto(buffer.slice(i, i + 50_000), fileName, messageId, false, false)); + await When(() => MainRc.RtcSession.DataChannel.bufferedAmount == 0, 10); + }, async () => { + await MainRc.RCHubConnection.SendFile(buffer.slice(i, i + 50_000), fileName, messageId, false, false); + }); + + if (i > 0) { + FileTransferProgress.value = i / buffer.byteLength; + } + } + + this.SendToAgent(() => MainRc.RtcSession.SendDto(new FileDto(null, fileName, messageId, true, false)), + () => MainRc.RCHubConnection.SendFile(null, fileName, messageId, true, false)); + } + + SendQualityChange(qualityLevel: number) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new QualityChangeDto(qualityLevel)), + () => MainRc.RCHubConnection.SendQualityChange(qualityLevel)); + } + SendAutoQualityAdjust(isOn: boolean) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new AutoQualityAdjustDto(isOn)), + () => MainRc.RCHubConnection.SendAutoQualityAdjust(isOn)); + } + SendToggleAudio(toggleOn: boolean) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new ToggleAudioDto(toggleOn)), + () => MainRc.RCHubConnection.SendToggleAudio(toggleOn)); + }; + SendToggleBlockInput(toggleOn: boolean) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new ToggleBlockInputDto(toggleOn)), + () => MainRc.RCHubConnection.SendToggleBlockInput(toggleOn)); + } + SendClipboardTransfer(text: string, typeText: boolean) { + this.SendToAgent(() => MainRc.RtcSession.SendDto(new ClipboardTransferDto(text, typeText)), + () => MainRc.RCHubConnection.SendClipboardTransfer(text, typeText)); + } + + private IsWebRtcAvailable() { + return MainRc.RtcSession.DataChannel && MainRc.RtcSession.DataChannel.readyState == "open"; + } + + private SendToAgent(rtcSend: () => void, websocketSend: () => void) { + if (MainRc.RtcSession.DataChannel && MainRc.RtcSession.DataChannel.readyState == "open") { + rtcSend(); + } + else if (MainRc.RCHubConnection.Connection.connectionStarted) { + websocketSend(); + } + } + + private async SendToAgentAsync(rtcSend: () => Promise, websocketSend: () => Promise) { + if (this.IsWebRtcAvailable()) { + await rtcSend(); + } + else { + await websocketSend(); + } + } + + } \ No newline at end of file