void NegotiateDesktop() { byte shareDesktopSetting = _c.ReceiveByte();//是否同意分享屏幕 bool shareDesktop = shareDesktopSetting != 0; var e = new CreatingDesktopEventArgs(shareDesktop); OnCreatingDesktop(e); var fbSource = _fbSource; Framebuffer = fbSource != null?fbSource.Capture() : null; VncStream.Require(Framebuffer != null, "No framebuffer. Make sure you've called SetFramebufferSource. It can be set to a VncFramebuffer.", VncFailureReason.SanityCheckFailed); _clientPixelFormat = Framebuffer.PixelFormat; _clientWidth = Framebuffer.Width; _clientHeight = Framebuffer.Height; _fbuAutoCache = null; _c.SendUInt16BE((ushort)Framebuffer.Width); _c.SendUInt16BE((ushort)Framebuffer.Height); var pixelFormat = new byte[VncPixelFormat.Size]; Framebuffer.PixelFormat.Encode(pixelFormat, 0); _c.Send(pixelFormat); _c.SendString(Framebuffer.Name, true); }
private void NegotiateDesktop() { Logger.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); Logger.Info($"The desktop {this.Framebuffer.Name} has initialized with pixel format {this.clientPixelFormat}; the screen size is {this.clientWidth}x{this.clientHeight}"); }
bool FramebufferSendChanges() { var e = new FramebufferUpdatingEventArgs(); lock (FramebufferUpdateRequestLock) { if (FramebufferUpdateRequest != null) { var fbSource = _fbSource; if (fbSource != null) { var newFramebuffer = fbSource.Capture(); if (newFramebuffer != null && newFramebuffer != Framebuffer) { Framebuffer = newFramebuffer; } } OnFramebufferCapturing(); OnFramebufferUpdating(e); if (!e.Handled) { if (_fbuAutoCache == null || _fbuAutoCache.Framebuffer != Framebuffer) { _fbuAutoCache = new VncFramebufferCache(Framebuffer); } e.Handled = true; e.SentChanges = _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 = new VncFramebufferCache(this.Framebuffer); } e.Handled = true; e.SentChanges = this.fbuAutoCache.RespondToUpdateRequest(this); } } } return e.SentChanges; }
private void NegotiateDesktop() { Logger.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); Logger.Info($"The desktop {this.Framebuffer.Name} has initialized with pixel format {this.clientPixelFormat}; the screen size is {this.clientWidth}x{this.clientHeight}"); }