public override Server creack(String ip, int port, String username, String password, int timeOut) { VncClient vc = null; Server server = new Server(); try { vc = new VncClient(); Boolean result = vc.Connect(ip, 0, port); if (result) { server.isSuccess = vc.Authenticate(password); } } catch (Exception e) { throw e; } finally { if (vc != null) { vc.Disconnect(); } } return(server); }
private void TestConfig(MainWindowViewModel vm) { using (var client = new VncClient(config.BitsPerPixel, config.Depth)) { try { client.Connect(vm.Host, vm.Port); client.Authenticate(new VncAuthenticator(vm.Password)); client.Disconnect(); MessageBox.Show("OK.", "Config", MessageBoxButton.OK, MessageBoxImage.Information); } catch (SocketException e) { MessageBox.Show(e.Message, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); } catch (VncSecurityException e) { MessageBox.Show(e.Message, Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); } catch (Exception e) { MessageBox.Show($"{e.Message}\r\n{e.StackTrace}", Strings.Error, MessageBoxButton.OK, MessageBoxImage.Error); } } }
private async void Page_Loaded(object sender, RoutedEventArgs e) { var config = await ReadConfigAsync(); _VncClient = new VncClient(config.BitsPerPixel, config.Depth); _VncClient.Connect(config.Host, config.Port); var auth = new VncAuthenticator(config.Password); _VncClient.Authenticate(auth); _VncClient.Initialize(); _VncImage = new WriteableBitmap(_VncClient.Framebuffer.Width, _VncClient.Framebuffer.Height); VncImage.Source = _VncImage; _VncClient.OnFramebufferUpdate += _VncClient_OnFramebufferUpdate; _VncClient.ReceiveUpdates(); }
/// <summary> /// Authenticate with the VNC Host using a user supplied password. /// </summary> /// <exception cref="System.InvalidOperationException">Thrown if the RemoteDesktop control is already Connected. See <see cref="VncSharp.RemoteDesktop.IsConnected" />.</exception> /// <exception cref="System.NullReferenceException">Thrown if the password is null.</exception> /// <param name="password">The user's password.</param> public void Authenticate(string password) { InsureConnection(false); if (!passwordPending) { throw new InvalidOperationException("Authentication is only required when Connect() returns True and the VNC Host requires a password."); } if (password == null) { throw new NullReferenceException("password"); } passwordPending = false; // repeated calls to Authenticate should fail. if (vnc.Authenticate(password)) { Initialize(); } else { OnConnectionLost(); } }