void ThreadMain() { var requester = new Utility.PeriodicThread(); IsConnected = true; OnConnected(); try { requester.Start(() => { SendFramebufferUpdateRequest(true); return(true); }, () => MaxUpdateRate, true); while (true) { var command = _c.ReceiveByte(); switch (command) { case 0: requester.Signal(); HandleFramebufferUpdate(); break; case 1: HandleSetColorMapEntries(); break; case 2: HandleBell(); break; case 3: HandleReceiveClipboardData(); break; default: VncStream.Require(false, "Unsupported command.", VncFailureReason.UnrecognizedProtocolElement); break; } } } catch (ObjectDisposedException) { } catch (IOException) { } catch (VncException) { } requester.Stop(); _c.Stream = null; IsConnected = false; OnClosed(); }
private void ThreadMain() { this.requester = new Utility.PeriodicThread(); try { this.InitFramebufferEncoder(); AuthenticationMethod[] methods; if (this.NegotiateVersion(out methods) && this.NegotiateSecurity(methods)) { this.NegotiateDesktop(); this.requester.Start(() => this.FramebufferSendChanges(), () => this.MaxUpdateRate, false); this.IsConnected = true; this.logger?.LogInformation("The client has connected successfully"); this.OnConnected(); while (true) { this.HandleMessage(); } } } catch (Exception exception) { this.logger?.LogError(new EventId(1), exception, $"VNC server session stopped due to: {exception.Message}"); } this.requester.Stop(); this.c.Stream = null; if (this.IsConnected) { this.IsConnected = false; this.OnClosed(); } else { this.OnConnectionFailed(); } }
private void ThreadMain() { var requester = new Utility.PeriodicThread(); this.IsConnected = true; this.OnConnected(); try { requester.Start( () => { this.SendFramebufferUpdateRequest(true); }, () => this.MaxUpdateRate, true); while (true) { this.HandleResponse(requester); } } catch (ObjectDisposedException) { } catch (IOException) { } catch (VncException) { } requester.Stop(); this.c.Stream = null; this.IsConnected = false; this.OnClosed(); }
private void ThreadMain() { this.requester = new Utility.PeriodicThread(); try { this.InitFramebufferEncoder(); AuthenticationMethod[] methods; this.NegotiateVersion(out methods); this.NegotiateSecurity(methods); this.NegotiateDesktop(); this.NegotiateEncodings(); this.requester.Start(() => this.FramebufferSendChanges(), () => this.MaxUpdateRate, false); this.IsConnected = true; this.logger?.Log(LogLevel.Info, () => "The client has connected successfully"); this.OnConnected(); while (true) { var command = (VncMessageType)this.c.ReceiveByte(); this.logger?.Log(LogLevel.Info, () => $"Received the {command} command."); switch (command) { case VncMessageType.SetPixelFormat: this.HandleSetPixelFormat(); break; case VncMessageType.SetEncodings: this.HandleSetEncodings(); break; case VncMessageType.FrameBufferUpdateRequest: this.HandleFramebufferUpdateRequest(); break; case VncMessageType.KeyEvent: this.HandleKeyEvent(); break; case VncMessageType.PointerEvent: this.HandlePointerEvent(); break; case VncMessageType.ClientCutText: this.HandleReceiveClipboardData(); break; default: VncStream.Require( false, "Unsupported command.", VncFailureReason.UnrecognizedProtocolElement); break; } } } catch (Exception exception) { this.logger?.Log(LogLevel.Error, () => $"VNC server session stopped due to: {exception.Message}"); } this.requester.Stop(); this.c.Stream = null; if (this.IsConnected) { this.IsConnected = false; this.OnClosed(); } else { this.OnConnectionFailed(); } }
private void ThreadMain() { this.requester = new Utility.PeriodicThread(); try { this.InitFramebufferEncoder(); AuthenticationMethod[] methods; this.NegotiateVersion(out methods); this.NegotiateSecurity(methods); this.NegotiateDesktop(); this.NegotiateEncodings(); this.requester.Start(() => this.FramebufferSendChanges(), () => this.MaxUpdateRate, false); this.IsConnected = true; Logger.Info("The client has connected successfully"); this.OnConnected(); while (true) { var command = (VncMessageType)this.c.ReceiveByte(); Logger.Info($"Received the {command} command."); switch (command) { case VncMessageType.SetPixelFormat: this.HandleSetPixelFormat(); break; case VncMessageType.SetEncodings: this.HandleSetEncodings(); break; case VncMessageType.FrameBufferUpdateRequest: this.HandleFramebufferUpdateRequest(); break; case VncMessageType.KeyEvent: this.HandleKeyEvent(); break; case VncMessageType.PointerEvent: this.HandlePointerEvent(); break; case VncMessageType.ClientCutText: this.HandleReceiveClipboardData(); break; default: VncStream.Require( false, "Unsupported command.", VncFailureReason.UnrecognizedProtocolElement); break; } } } catch (ObjectDisposedException) { } catch (IOException) { } catch (VncException) { } this.requester.Stop(); this.c.Stream = null; if (this.IsConnected) { this.IsConnected = false; this.OnClosed(); } else { this.OnConnectionFailed(); } }
void ThreadMain() { _requester = new Utility.PeriodicThread(); try { InitFramebufferEncoder(); AuthenticationMethod[] methods; NegotiateVersion(out methods); NegotiateSecurity(methods); NegotiateDesktop();//绘画的桌面 NegotiateEncodings(); _requester.Start(FramebufferSendChanges, () => MaxUpdateRate, false); IsConnected = true; OnConnected(); while (true) { var command = _c.ReceiveByte(); switch (command) { case 0: HandleSetPixelFormat(); break; case 2: HandleSetEncodings(); break; case 3: HandleFramebufferUpdateRequest(); break; case 4: HandleKeyEvent(); break; case 5: HandlePointerEvent(); break; case 6: HandleReceiveClipboardData(); break; default: VncStream.Require(false, "Unsupported command.", VncFailureReason.UnrecognizedProtocolElement); break; } } } catch (ObjectDisposedException ex) { } catch (IOException ex) { } catch (VncException ex) { //Vnc错误 } _requester.Stop(); _c.Stream = null; if (IsConnected) { IsConnected = false; OnClosed(); } else { OnConnectionFailed(); } }
private void ThreadMain() { var requester = new Utility.PeriodicThread(); this.IsConnected = true; this.OnConnected(); try { requester.Start( () => { this.SendFramebufferUpdateRequest(true); }, () => this.MaxUpdateRate, true); while (true) { var command = this.c.ReceiveByte(); switch (command) { case 0: requester.Signal(); this.HandleFramebufferUpdate(); break; case 1: this.HandleSetColorMapEntries(); break; case 2: this.HandleBell(); break; case 3: this.HandleReceiveClipboardData(); break; default: VncStream.Require( false, "Unsupported command.", VncFailureReason.UnrecognizedProtocolElement); break; } } } catch (ObjectDisposedException) { } catch (IOException) { } catch (VncException) { } requester.Stop(); this.c.Stream = null; this.IsConnected = false; this.OnClosed(); }