public void Start() { if (string.IsNullOrEmpty(Name)) { throw new ArgumentNullException("Name", "The VNC Server Name cannot be empty."); } if (Port == 0) { throw new ArgumentNullException("Port", "The VNC Server port cannot be zero."); } if (ProxyPort == 0) { throw new ArgumentNullException("ProxyPort", "You must set a proxy port."); } new Thread(() => { Console.WriteLine("Started VNC Server at port: " + Port + " and proxy port at: " + ProxyPort); proxy = new VncProxy(Path, ProxyPort, Port); proxy.StartWebsockify(); host = new VncHost(Port, Name, new ScreenHandler(new Rectangle(0, 0, ScreenSize().Width, ScreenSize().Height), true)); host.WriteProtocolVersion(); Console.WriteLine("Wrote Protocol Version"); host.ReadProtocolVersion(); Console.WriteLine("Read Protocol Version"); Console.WriteLine("Awaiting Authentication"); if (!host.WriteAuthentication(Password)) { Console.WriteLine("Authentication failed !"); Stop(); //Start(); } else { Console.WriteLine("Authentication successfull !"); var share = host.ReadClientInit(); Console.WriteLine("Share: " + share); Console.WriteLine("Server name: " + fb.DesktopName); host.WriteServerInit(fb); while (host.isRunning) { switch (host.ReadServerMessageType()) { case VncHost.ClientMessages.SetPixelFormat: Console.WriteLine("Read SetPixelFormat"); var f = host.ReadSetPixelFormat(fb.Width, fb.Height); if (f != null) { fb = f; } break; case VncHost.ClientMessages.ReadColorMapEntries: Console.WriteLine("Read ReadColorMapEntry"); host.ReadColorMapEntry(); break; case VncHost.ClientMessages.SetEncodings: Console.WriteLine("Read SetEncodings"); host.ReadSetEncodings(); break; case VncHost.ClientMessages.FramebufferUpdateRequest: Console.WriteLine("Read FrameBufferUpdateRequest"); host.ReadFrameBufferUpdateRequest(fb); break; case VncHost.ClientMessages.KeyEvent: Console.WriteLine("Read KeyEvent"); host.ReadKeyEvent(); break; case VncHost.ClientMessages.PointerEvent: Console.WriteLine("Read PointerEvent"); host.ReadPointerEvent(); break; case VncHost.ClientMessages.ClientCutText: Console.WriteLine("Read CutText"); host.ReadClientCutText(); break; } } if (!host.isRunning) { Console.WriteLine("Stopping Websockify"); } proxy.StopWebsockify(); //Start(); } }).Start(); }
public void Start() { if (String.IsNullOrEmpty(Name)) throw new ArgumentNullException("Name", "The VNC Server Name cannot be empty."); if (Port == 0) throw new ArgumentNullException("Port", "The VNC Server port cannot be zero."); Console.WriteLine("Started VNC Server at port: " + Port); host = new VncHost(Port, Name, new ScreenHandler(new Rectangle(0, 0, ScreenSize().Width, ScreenSize().Height), true)); host.WriteProtocolVersion(); Console.WriteLine("Wrote Protocol Version"); host.ReadProtocolVersion(); Console.WriteLine("Read Protocol Version"); Console.WriteLine("Awaiting Authentication"); if (!host.WriteAuthentication(Password)) { Console.WriteLine("Authentication failed !"); host.Close(); //Start(); } else { Console.WriteLine("Authentication successfull !"); bool share = host.ReadClientInit(); Console.WriteLine("Share: " + share); Console.WriteLine("Server name: " + fb.DesktopName); host.WriteServerInit(fb); while ((host.isRunning)) { switch (host.ReadServerMessageType()) { case VncHost.ClientMessages.SetPixelFormat: Console.WriteLine("Read SetPixelFormat"); Framebuffer f = host.ReadSetPixelFormat(fb.Width, fb.Height); if (f != null) fb = f; break; case VncHost.ClientMessages.ReadColorMapEntries: Console.WriteLine("Read ReadColorMapEntry"); host.ReadColorMapEntry(); break; case VncHost.ClientMessages.SetEncodings: Console.WriteLine("Read SetEncodings"); host.ReadSetEncodings(); break; case VncHost.ClientMessages.FramebufferUpdateRequest: Console.WriteLine("Read FrameBufferUpdateRequest"); host.ReadFrameBufferUpdateRequest(fb); break; case VncHost.ClientMessages.KeyEvent: Console.WriteLine("Read KeyEvent"); host.ReadKeyEvent(); break; case VncHost.ClientMessages.PointerEvent: Console.WriteLine("Read PointerEvent"); host.ReadPointerEvent(); break; case VncHost.ClientMessages.ClientCutText: Console.WriteLine("Read CutText"); host.ReadClientCutText(); break; } } //if (!host.isRunning) //Start(); } }
public void Start() { if (String.IsNullOrEmpty(Name)) { throw new ArgumentNullException("Name", "The VNC Server Name cannot be empty."); } if (Port == 0) { throw new ArgumentNullException("Port", "The VNC Server port cannot be zero."); } Console.WriteLine("Started VNC Server at port: " + Port); host = new VncHost(Port, Name); host.Start(); host.WriteProtocolVersion(); Console.WriteLine("Wrote Protocol Version"); host.ReadProtocolVersion(); Console.WriteLine("Read Protocol Version"); Console.WriteLine("Awaiting Authentication"); if (!host.WriteAuthentication(Password)) { Console.WriteLine("Authentication failed !"); host.Close(); //Start(); } else { Console.WriteLine("Authentication successfull !"); bool share = host.ReadClientInit(); Console.WriteLine("Share: " + share); Console.WriteLine("Server name: " + fb.DesktopName); host.WriteServerInit(fb); while ((host.isRunning)) { switch (host.ReadServerMessageType()) { case VncHost.ClientMessages.SetPixelFormat: Console.WriteLine("Read SetPixelFormat"); Framebuffer f = host.ReadSetPixelFormat(fb.Width, fb.Height); if (f != null) { fb = f; } break; case VncHost.ClientMessages.ReadColorMapEntries: Console.WriteLine("Read ReadColorMapEntry"); host.ReadColorMapEntry(); break; case VncHost.ClientMessages.SetEncodings: Console.WriteLine("Read SetEncodings"); host.ReadSetEncodings(); break; case VncHost.ClientMessages.FramebufferUpdateRequest: Console.WriteLine("Read FrameBufferUpdateRequest"); host.ReadFrameBufferUpdateRequest(fb); break; case VncHost.ClientMessages.KeyEvent: Console.WriteLine("Read KeyEvent"); host.ReadKeyEvent(); break; case VncHost.ClientMessages.PointerEvent: Console.WriteLine("Read PointerEvent"); host.ReadPointerEvent(); break; case VncHost.ClientMessages.ClientCutText: Console.WriteLine("Read CutText"); host.ReadClientCutText(); break; } } //if (!host.isRunning) //Start(); } }
public virtual void Start() { if (String.IsNullOrEmpty(Name)) { throw new ArgumentNullException("Name", "The VNC Server Name cannot be empty."); } if (Port == 0) { throw new ArgumentNullException("Port", "The VNC Server port cannot be zero."); } Console.WriteLine("Started VNC Server at port: " + Port); host = new VncHost(Port, Name, new ScreenHandler(new Rectangle(0, 0, ScreenSize().Width, ScreenSize().Height), true)); host.Start(this); host.WriteProtocolVersion(); Console.WriteLine("Wrote Protocol Version"); host.ReadProtocolVersion(); Console.WriteLine("Read Protocol Version"); Console.WriteLine("Awaiting Authentication"); if (!host.WriteAuthentication(Password)) { Console.WriteLine("Authentication failed !"); #if DEBUG //Start(); if (!Debugger.IsAttached) { host.Close(); return; } #else host.Close(); return; #endif } // else { Console.WriteLine("Authentication successfull !"); bool share = host.ReadClientInit(); Console.WriteLine("Share: " + share); Console.WriteLine("Server name: " + fb.DesktopName); host.WriteServerInit(fb); if (!host.isRunning) { Console.WriteLine("host.isRunning = false"); return; } while ((host.isRunning)) { switch (host.ReadServerMessageType()) { case VncHost.ClientMessages.Error: break; case VncHost.ClientMessages.SetPixelFormat: Console.WriteLine("Read SetPixelFormat"); Framebuffer f = host.ReadSetPixelFormat(fb.Width, fb.Height); if (f != null) { fb = f; } break; case VncHost.ClientMessages.ReadColorMapEntries: Console.WriteLine("Read ReadColorMapEntry"); host.ReadColorMapEntry(); break; case VncHost.ClientMessages.SetEncodings: Console.WriteLine("Read SetEncodings"); host.ReadSetEncodings(); break; case VncHost.ClientMessages.FramebufferUpdateRequest: Console.WriteLine("Read FrameBufferUpdateRequest"); host.ReadFrameBufferUpdateRequest(fb); break; case VncHost.ClientMessages.KeyEvent: Console.WriteLine("Read KeyEvent"); host.ReadKeyEvent(); break; case VncHost.ClientMessages.PointerEvent: Console.WriteLine("Read PointerEvent"); host.ReadPointerEvent(); break; case VncHost.ClientMessages.ClientCutText: Console.WriteLine("Read CutText"); host.ReadClientCutText(); break; } } //if (!host.isRunning) //Start(); } }