C# Class VncSharpWpf.VncClient

ファイルを表示 Open project: nakano531/VncSharpWpf Class Usage Examples

Public Methods

Method Description
Authenticate ( string password ) : bool

Use a password to authenticate with a VNC Host. NOTE: This is only necessary if Connect() returns TRUE.

Connect ( string host ) : bool

Connect to a VNC Host and determine which type of Authentication it uses. If the host uses Password Authentication, a call to Authenticate() will be required. Default Display and Port numbers are used.

Connect ( string host, int display ) : bool

Connect to a VNC Host and determine which type of Authentication it uses. If the host uses Password Authentication, a call to Authenticate() will be required. The Port number is calculated based on the Display.

Connect ( string host, int display, int port ) : bool
Connect ( string host, int display, int port, bool viewOnly ) : bool

Connect to a VNC Host and determine which type of Authentication it uses. If the host uses Password Authentication, a call to Authenticate() will be required.

Disconnect ( ) : void

Stops sending requests for updates and disconnects from the remote host. You must call Connect() again if you wish to re-establish a connection.

Initialize ( ) : void

Finish setting-up protocol with VNC Host. Should be called after Connect and Authenticate (if password required).

Listen ( string host, int port, bool viewOnly ) : void

Wait for a connection from VNC Server.

RequestScreenUpdate ( bool refreshFullScreen ) : void

Requests that the remote host send a screen update.

RequestScreenUpdate needs to be called whenever the client screen needs to be updated to reflect the state of the remote desktop. Typically you only need to have a particular region of the screen updated and can still use the rest of the pixels on the client-side (i.e., when moving the mouse pointer, only the area around the pointer changes). Therefore, you should almost always set refreshFullScreen to FALSE. If the client-side image becomes corrupted, call RequestScreenUpdate with refreshFullScreen set to TRUE to get the complete image sent again.

SetInputMode ( bool viewOnly ) : void

Changes the input mode to view-only or interactive.

StartUpdates ( ) : void

Begin getting updates from the VNC Server. This will continue until StopUpdates() is called. NOTE: this must be called after Connect().

StopListen ( ) : void
VncClient ( ) : System
WriteClientCutText ( string text ) : void
WriteKeyboardEvent ( uint keysym, bool pressed ) : void
WritePointerEvent ( byte buttonMask, Point point ) : void

Protected Methods

Method Description
EncryptChallenge ( string password, byte challenge ) : byte[]

Encrypts a challenge using the specified password. See RFB Protocol Document v. 3.8 section 6.2.2.

GetSupportedSecurityType ( byte types ) : byte

Examines a list of Security Types supported by a VNC Server and chooses one that the Client supports. See 6.1.2 of the RFB Protocol document v. 3.8.

OnConnectionLost ( ) : void
OnServerCutText ( ) : void
PerformVncAuthentication ( string password ) : void

Performs VNC Authentication using VNC DES encryption. See the RFB Protocol doc 6.2.2.

Private Methods

Method Description
Beep ( int freq, int duration ) : bool
CheckIfThreadDone ( ) : bool
ConnectCore ( string host, int display, int &port, bool viewOnly, bool connectFromClient ) : bool

Main Function for Connect Process.

ConnectedFromServerEventHandler ( object sender, EventArgs e ) : void

EventHandler for event "ConnectedFromServer"

DoHandShake ( ) : bool
FailedToListenHandler ( object sender, EventArgs e ) : void

EventHandler for event "FailedToListen"

GetRfbUpdates ( ) : void

Worker thread lives here and processes protocol messages infinitely, triggering events or other actions as necessary.

Method Details

Authenticate() public method

Use a password to authenticate with a VNC Host. NOTE: This is only necessary if Connect() returns TRUE.
public Authenticate ( string password ) : bool
password string The password to use.
return bool

Connect() public method

Connect to a VNC Host and determine which type of Authentication it uses. If the host uses Password Authentication, a call to Authenticate() will be required. Default Display and Port numbers are used.
public Connect ( string host ) : bool
host string The IP Address or Host Name of the VNC Host.
return bool

Connect() public method

Connect to a VNC Host and determine which type of Authentication it uses. If the host uses Password Authentication, a call to Authenticate() will be required. The Port number is calculated based on the Display.
public Connect ( string host, int display ) : bool
host string The IP Address or Host Name of the VNC Host.
display int The Display number (used on Unix hosts).
return bool

Connect() public method

public Connect ( string host, int display, int port ) : bool
host string
display int
port int
return bool

Connect() public method

Connect to a VNC Host and determine which type of Authentication it uses. If the host uses Password Authentication, a call to Authenticate() will be required.
public Connect ( string host, int display, int port, bool viewOnly ) : bool
host string The IP Address or Host Name of the VNC Host.
display int The Display number (used on Unix hosts).
port int The Port number used by the Host, usually 5900.
viewOnly bool True if mouse/keyboard events are to be ignored.
return bool

Disconnect() public method

Stops sending requests for updates and disconnects from the remote host. You must call Connect() again if you wish to re-establish a connection.
public Disconnect ( ) : void
return void

EncryptChallenge() protected method

Encrypts a challenge using the specified password. See RFB Protocol Document v. 3.8 section 6.2.2.
protected EncryptChallenge ( string password, byte challenge ) : byte[]
password string The user's password.
challenge byte The challenge sent by the server.
return byte[]

GetSupportedSecurityType() protected method

Examines a list of Security Types supported by a VNC Server and chooses one that the Client supports. See 6.1.2 of the RFB Protocol document v. 3.8.
protected GetSupportedSecurityType ( byte types ) : byte
types byte An array of bytes representing the Security Types supported by the VNC Server.
return byte

Initialize() public method

Finish setting-up protocol with VNC Host. Should be called after Connect and Authenticate (if password required).
public Initialize ( ) : void
return void

Listen() public method

Wait for a connection from VNC Server.
public Listen ( string host, int port, bool viewOnly ) : void
host string
port int
viewOnly bool
return void

OnConnectionLost() protected method

protected OnConnectionLost ( ) : void
return void

OnServerCutText() protected method

protected OnServerCutText ( ) : void
return void

PerformVncAuthentication() protected method

Performs VNC Authentication using VNC DES encryption. See the RFB Protocol doc 6.2.2.
protected PerformVncAuthentication ( string password ) : void
password string A string containing the user's password in clear text format.
return void

RequestScreenUpdate() public method

Requests that the remote host send a screen update.
RequestScreenUpdate needs to be called whenever the client screen needs to be updated to reflect the state of the remote desktop. Typically you only need to have a particular region of the screen updated and can still use the rest of the pixels on the client-side (i.e., when moving the mouse pointer, only the area around the pointer changes). Therefore, you should almost always set refreshFullScreen to FALSE. If the client-side image becomes corrupted, call RequestScreenUpdate with refreshFullScreen set to TRUE to get the complete image sent again.
public RequestScreenUpdate ( bool refreshFullScreen ) : void
refreshFullScreen bool TRUE if the entire screen should be refreshed, FALSE if only a partial region needs updating.
return void

SetInputMode() public method

Changes the input mode to view-only or interactive.
public SetInputMode ( bool viewOnly ) : void
viewOnly bool True if view-only mode is desired (no mouse/keyboard events will be sent).
return void

StartUpdates() public method

Begin getting updates from the VNC Server. This will continue until StopUpdates() is called. NOTE: this must be called after Connect().
public StartUpdates ( ) : void
return void

StopListen() public method

public StopListen ( ) : void
return void

VncClient() public method

public VncClient ( ) : System
return System

WriteClientCutText() public method

public WriteClientCutText ( string text ) : void
text string
return void

WriteKeyboardEvent() public method

public WriteKeyboardEvent ( uint keysym, bool pressed ) : void
keysym uint
pressed bool
return void

WritePointerEvent() public method

public WritePointerEvent ( byte buttonMask, Point point ) : void
buttonMask byte
point Point
return void