* Adding noVNC repo * Adding support for noVNC * Adding Ctl+Esc * Removing device name from novnc header
11 KiB
noVNC API
The interface of the noVNC client consists of a single RFB object that is instantiated once per connection.
RFB
The RFB object represents a single connection to a VNC server. It
communicates using a WebSocket that must provide a standard RFB
protocol stream.
Constructor
- Creates and returns a new
RFBobject.
Properties
viewOnly
- Is a
booleanindicating if any events (e.g. key presses or mouse movement) should be prevented from being sent to the server. Disabled by default.
focusOnClick
- Is a
booleanindicating if keyboard focus should automatically be moved to the remote session when amousedownortouchstartevent is received.
touchButton
- Is a
longcontrolling the button mask that should be simulated when a touch event is recieved. Uses the same values asMouseEvent.button. Is set to1by default.
clipViewport
- Is a
booleanindicating if the remote session should be clipped to its container. When disabled scrollbars will be shown to handle the resulting overflow. Disabled by default.
dragViewport
- Is a
booleanindicating if mouse events should control the relative position of a clipped remote session. Only relevant ifclipViewportis enabled. Disabled by default.
scaleViewport
- Is a
booleanindicating if the remote session should be scaled locally so it fits its container. When disabled it will be centered if the remote session is smaller than its container, or handled according toclipViewportif it is larger. Disabled by default.
resizeSession
- Is a
booleanindicating if a request to resize the remote session should be sent whenever the container changes dimensions. Disabled by default.
showDotCursor
- Is a
booleanindicating whether a dot cursor should be shown instead of a zero-sized or fully-transparent cursor if the server sets such invisible cursor. Disabled by default.
background
- Is a valid CSS background
style value indicating which background style should be applied
to the element containing the remote session screen. The default value is
rgb(40, 40, 40)(solid gray color).
capabilities Read only
- Is an
Objectindicating which optional extensions are available on the server. Some methods may only be called if the corresponding capability is set. The following capabilities are defined:name type description powerbooleanMachine power control is available
Events
- The
connectevent is fired when theRFBobject has completed the connection and handshaking with the server.
- The
disconnectevent is fired when theRFBobject disconnects.
- The
credentialsrequiredevent is fired when more credentials must be given to continue.
- The
securityfailureevent is fired when the security negotiation with the server fails.
- The
clipboardevent is fired when clipboard data is received from the server.
- The
bellevent is fired when a audible bell request is received from the server.
- The
desktopnameevent is fired when the remote desktop name changes.
- The
capabilitiesevent is fired whenRFB.capabilitiesis updated.
Methods
- Disconnect from the server.
- Send credentials to server. Should be called after the
credentialsrequiredevent has fired.
- Send a key event.
- Send Ctrl-Alt-Del key sequence.
- Move keyboard focus to the remote session.
- Remove keyboard focus from the remote session.
- Request a shutdown of the remote machine.
- Request a reboot of the remote machine.
- Request a reset of the remote machine.
- Send clipboard contents to server.
Details
RFB()
The RFB() constructor returns a new RFB object and initiates a new
connection to a specified VNC server.
Syntax
let rfb = new RFB( target, url [, options] );
Parameters
target
- A block
HTMLElementthat specifies where theRFBobject should attach itself. The existing contents of theHTMLElementwill be untouched, but new elements will be added during the lifetime of theRFBobject.
url
- A
DOMStringspecifying the VNC server to connect to. This must be a valid WebSocket URL.
options Optional
-
An
Objectspecifying extra details about how the connection should be made.Possible options:
shared- A
booleanindicating if the remote server should be shared or if any other connected clients should be disconnected. Enabled by default.
credentials- An
Objectspecifying the credentials to provide to the server when authenticating. The following credentials are possible:name type description "username"DOMStringThe user that authenticates "password"DOMStringPassword for the user "target"DOMStringTarget machine or session
repeaterID- A
DOMStringspecifying the ID to provide to any VNC repeater encountered.
- A
connect
The connect event is fired after all the handshaking with the server
is completed and the connection is fully established. After this event
the RFB object is ready to recieve graphics updates and to send input.
disconnect
The disconnect event is fired when the connection has been
terminated. The detail property is an Object that contains the
property clean. clean is a boolean indicating if the termination
was clean or not. In the event of an unexpected termination or an error
clean will be set to false.
credentialsrequired
The credentialsrequired event is fired when the server requests more
credentials than were specified to RFB(). The detail
property is an Object containing the property types which is an
Array of DOMString listing the credentials that are required.
securityfailure
The securityfailure event is fired when the handshaking process with
the server fails during the security negotiation step. The detail
property is an Object containing the following properties:
| Property | Type | Description |
|---|---|---|
status |
long |
The failure status code |
reason |
DOMString |
The optional reason for the failure |
The property status corresponds to the
SecurityResult
status code in cases of failure. A status of zero will not be sent in
this event since that indicates a successful security handshaking
process. The optional property reason is provided by the server and
thus the language of the string is not known. However most servers will
probably send English strings. The server can choose to not send a
reason and in these cases the reason property will be omitted.
clipboard
The clipboard event is fired when the server has sent clipboard data.
The detail property is an Object containing the property text
which is a DOMString with the clipboard data.
bell
The bell event is fired when the server has requested an audible
bell.
desktopname
The desktopname event is fired when the name of the remote desktop
changes. The detail property is an Object with the property name
which is a DOMString specifying the new name.
capabilities
The capabilities event is fired whenever an entry is added or removed
from RFB.capabilities. The detail property is an Object with the
property capabilities containing the new value of RFB.capabilities.
RFB.disconnect()
The RFB.disconnect() method is used to disconnect from the currently
connected server.
Syntax
RFB.disconnect( );
RFB.sendCredentials()
The RFB.sendCredentials() method is used to provide the missing
credentials after a credentialsrequired event has been fired.
Syntax
RFB.sendCredentials( credentials );
Parameters
credentials
- An
Objectspecifying the credentials to provide to the server when authenticating. SeeRFB()for details.
RFB.sendKey()
The RFB.sendKey() method is used to send a key event to the server.
Syntax
RFB.sendKey( keysym, code [, down] );
Parameters
keysym
- A
longspecifying the RFB keysym to send. Can be0if a validcodeis specified.
code
- A
DOMStringspecifying the physical key to send. Valid values are those that can be specified toKeyboardEvent.code. If the physical key cannot be determined thennullshall be specified.
down Optional
- A
booleanspecifying if a press or a release event should be sent. If omitted then both a press and release event are sent.
RFB.sendCtrlAltDel()
The RFB.sendCtrlAltDel() method is used to send the key sequence
left Control, left Alt, Delete. This is a convenience wrapper
around RFB.sendKey().
Syntax
RFB.sendCtrlAltDel( );
RFB.focus()
The RFB.focus() method sets the keyboard focus on the remote session.
Keyboard events will be sent to the remote server after this point.
Syntax
RFB.focus( );
RFB.blur()
The RFB.blur() method remove keyboard focus on the remote session.
Keyboard events will no longer be sent to the remote server after this
point.
Syntax
RFB.blur( );
RFB.machineShutdown()
The RFB.machineShutdown() method is used to request to shut down the
remote machine. The capability power must be set for this method to
have any effect.
Syntax
RFB.machineShutdown( );
RFB.machineReboot()
The RFB.machineReboot() method is used to request a clean reboot of
the remote machine. The capability power must be set for this method
to have any effect.
Syntax
RFB.machineReboot( );
RFB.machineReset()
The RFB.machineReset() method is used to request a forced reset of
the remote machine. The capability power must be set for this method
to have any effect.
Syntax
RFB.machineReset( );
RFB.clipboardPasteFrom()
The RFB.clipboardPasteFrom() method is used to send clipboard data
to the remote server.
Syntax
RFB.clipboardPasteFrom( text );
Parameters
text
- A
DOMStringspecifying the clipboard data to send. Currently only characters from ISO 8859-1 are supported.