public SetFramebufferSource ( IVncFramebufferSource source ) : void | ||
source | IVncFramebufferSource | The framebuffer source, or |
리턴 | void |
static void Main(string[] args) { Console.WriteLine("Listening on local port 5900."); Console.WriteLine("Try to connect! The password is: {0}", Password); // Wait for a connection. var listener = new TcpListener(IPAddress.Any, 5900); listener.Start(); var client = listener.AcceptTcpClient(); // Set up a framebuffer and options. var options = new VncServerSessionOptions(); options.AuthenticationMethod = AuthenticationMethod.Password; // Create a session. Session = new VncServerSession(); Session.Connected += HandleConnected; Session.ConnectionFailed += HandleConnectionFailed; Session.Closed += HandleClosed; Session.PasswordProvided += HandlePasswordProvided; Session.SetFramebufferSource(new VncScreenFramebufferSource("Hello World", Screen.PrimaryScreen)); Session.Connect(client.GetStream(), options); // Let's go. Application.Run(); }
/// <summary> /// The main loop of the VNC server. Listens for new connections, and spawns new <see cref="VncServerSession"/>s. /// </summary> /// <returns> /// A <see cref="Task"/> which represents the asynchronous operation. /// </returns> protected async Task Run() { while (true) { var client = await this.listener.AcceptTcpClientAsync(); // Set up a framebuffer and options. var options = new VncServerSessionOptions(); options.AuthenticationMethod = AuthenticationMethod.Password; // Create a session. var session = new VncServerSession( new VncPasswordChallenge(), this.logger); session.Connected += this.OnConnected; session.Closed += this.OnClosed; session.PasswordProvided += this.OnPasswordProvided; session.SetFramebufferSource(this.framebufferSource); session.Connect(client.GetStream(), options); if (this.keyboard != null) { session.KeyChanged += this.keyboard.HandleKeyEvent; } if (this.controller != null) { session.PointerChanged += this.controller.HandleTouchEvent; } this.sessions.Add(session); } }