private void NegotiateDesktop() { this.logger?.Log(LogLevel.Info, () => "Negotiating desktop settings"); byte shareDesktopSetting = this.c.ReceiveByte(); bool shareDesktop = shareDesktopSetting != 0; var e = new CreatingDesktopEventArgs(shareDesktop); this.OnCreatingDesktop(e); var fbSource = this.fbSource; this.Framebuffer = fbSource != null?fbSource.Capture() : null; VncStream.Require( this.Framebuffer != null, "No framebuffer. Make sure you've called SetFramebufferSource. It can be set to a VncFramebuffer.", VncFailureReason.SanityCheckFailed); this.clientPixelFormat = this.Framebuffer.PixelFormat; this.clientWidth = this.Framebuffer.Width; this.clientHeight = this.Framebuffer.Height; this.fbuAutoCache = null; this.c.SendUInt16BE((ushort)this.Framebuffer.Width); this.c.SendUInt16BE((ushort)this.Framebuffer.Height); var pixelFormat = new byte[VncPixelFormat.Size]; this.Framebuffer.PixelFormat.Encode(pixelFormat, 0); this.c.Send(pixelFormat); this.c.SendString(this.Framebuffer.Name, true); this.logger?.Log(LogLevel.Info, () => $"The desktop {this.Framebuffer.Name} has initialized with pixel format {this.clientPixelFormat}; the screen size is {this.clientWidth}x{this.clientHeight}"); }
internal bool FramebufferSendChanges() { var e = new FramebufferUpdatingEventArgs(); lock (this.FramebufferUpdateRequestLock) { if (this.FramebufferUpdateRequest != null) { var fbSource = this.fbSource; if (fbSource != null) { try { var newFramebuffer = fbSource.Capture(); if (newFramebuffer != null && newFramebuffer != this.Framebuffer) { this.Framebuffer = newFramebuffer; } } catch (Exception exc) { this.logger?.Log(LogLevel.Error, () => $"Capturing the framebuffer source failed: {exc}."); } } this.OnFramebufferCapturing(); this.OnFramebufferUpdating(e); if (!e.Handled) { if (this.fbuAutoCache == null || this.fbuAutoCache.Framebuffer != this.Framebuffer) { this.fbuAutoCache = this.CreateFramebufferCache(this.Framebuffer, this.logger); } e.Handled = true; e.SentChanges = this.fbuAutoCache.RespondToUpdateRequest(this); } } } return(e.SentChanges); }
private bool FramebufferSendChanges() { var e = new FramebufferUpdatingEventArgs(); lock (this.FramebufferUpdateRequestLock) { if (this.FramebufferUpdateRequest != null) { var fbSource = this.fbSource; if (fbSource != null) { var newFramebuffer = fbSource.Capture(); if (newFramebuffer != null && newFramebuffer != this.Framebuffer) { this.Framebuffer = newFramebuffer; } } this.OnFramebufferCapturing(); this.OnFramebufferUpdating(e); if (!e.Handled) { if (this.fbuAutoCache == null || this.fbuAutoCache.Framebuffer != this.Framebuffer) { this.fbuAutoCache = this.CreateFramebufferCache(this.Framebuffer, this.logger); } e.Handled = true; e.SentChanges = this.fbuAutoCache.RespondToUpdateRequest(this); } } } return(e.SentChanges); }
internal bool FramebufferSendChanges() { var e = new FramebufferUpdatingEventArgs(); lock (this.FramebufferUpdateRequestLock) { if (this.FramebufferUpdateRequest == null) { var incremental = false; if (regionCurr == -1) { regionCurr = 0; incremental = true; } ; var width = (Framebuffer.Width / regionSize); var height = Framebuffer.Height; var x = ((regionCurr % regionSize) * width); regionCurr++; if (regionCurr >= regionSize) { regionCurr = 0; } this.FramebufferUpdateRequest = new FramebufferUpdateRequest( incremental, new VncRectangle(x, 0, width, height)); } if (this.FramebufferUpdateRequest != null) { var fbSource = this.fbSource; if (fbSource != null) { //try //{ var newFramebuffer = fbSource.Capture(); if (newFramebuffer != null && newFramebuffer != this.Framebuffer) { this.Framebuffer = newFramebuffer; } //} //catch (Exception exc) //{ // this.logger?.Log(LogLevel.Error, () => $"Capturing the framebuffer source failed: {exc}."); //} } this.OnFramebufferCapturing(); this.OnFramebufferUpdating(e); if (!e.Handled) { if (this.fbuAutoCache == null || this.fbuAutoCache.Framebuffer != this.Framebuffer) { this.fbuAutoCache = this.CreateFramebufferCache(this.Framebuffer, this.logger); } e.Handled = true; e.SentChanges = this.fbuAutoCache.RespondToUpdateRequest(this); } } } return(e.SentChanges); }