Skip to content

Commit

Permalink
Revert message handler change.
Browse files Browse the repository at this point in the history
  • Loading branch information
bitbound committed Apr 29, 2021
1 parent aa5ff09 commit 6c21ffe
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 62 deletions.
47 changes: 19 additions & 28 deletions Server/wwwroot/src/RemoteControl/DtoMessageHandler.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/src/RemoteControl/DtoMessageHandler.js.map

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

56 changes: 23 additions & 33 deletions Server/wwwroot/src/RemoteControl/DtoMessageHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import {
WindowsSessionsDto
} from "./Interfaces/Dtos.js";
import { ReceiveFile } from "./FileTransferService.js";
import { When } from "./Utilities.js";

export class DtoMessageHandler {
MessagePack: any = window['MessagePack'];
ImagePartials: Record<string, Array<Uint8Array>> = {};
Rendering: boolean = false;

ParseBinaryMessage(data: ArrayBuffer) {
var model = this.MessagePack.decode(data) as BaseDto;
Expand Down Expand Up @@ -64,42 +62,34 @@ export class DtoMessageHandler {
HandleCaptureFrame(captureFrame: CaptureFrameDto) {

if (captureFrame.EndOfFrame) {
When(() => !this.Rendering, 10).then(() => {
if (this.Rendering) {
console.warn("Concurrency issue");
}
this.Rendering = true;

var partials = this.ImagePartials[captureFrame.Id];
let completedFrame = new Blob(partials);
this.ImagePartials[captureFrame.Id] = [];

let url = window.URL.createObjectURL(completedFrame);
let img = new Image(captureFrame.Width, captureFrame.Height);
img.onload = () => {
UI.Screen2DContext.drawImage(img,
captureFrame.Left,
captureFrame.Top,
captureFrame.Width,
captureFrame.Height);
window.URL.revokeObjectURL(url);
this.Rendering = false;
};
img.src = url;
var partials = this.ImagePartials[captureFrame.Id];
let completedFrame = new Blob(partials);
this.ImagePartials[captureFrame.Id] = [];

//createImageBitmap(completedFrame).then(bitmap => {
// UI.Screen2DContext.drawImage(bitmap,
// captureFrame.Left,
// captureFrame.Top,
// captureFrame.Width,
// captureFrame.Height);
let url = window.URL.createObjectURL(completedFrame);
let img = new Image(captureFrame.Width, captureFrame.Height);
img.onload = () => {
UI.Screen2DContext.drawImage(img,
captureFrame.Left,
captureFrame.Top,
captureFrame.Width,
captureFrame.Height);
window.URL.revokeObjectURL(url);
};
img.src = url;

// bitmap.close();
//})
//createImageBitmap(completedFrame).then(bitmap => {
// UI.Screen2DContext.drawImage(bitmap,
// captureFrame.Left,
// captureFrame.Top,
// captureFrame.Width,
// captureFrame.Height);

ViewerApp.MessageSender.SendFrameReceived();
});
// bitmap.close();
//})

ViewerApp.MessageSender.SendFrameReceived();
}
else {
if (!this.ImagePartials[captureFrame.Id]) {
Expand Down

0 comments on commit 6c21ffe

Please sign in to comment.