noVNC

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

RFB()

Properties

background

capabilities Read only

clippingViewport Read only

clipViewport

compressionLevel

dragViewport

focusOnClick

qualityLevel

resizeSession

scaleViewport

showDotCursor

viewOnly

Events

bell

capabilities

clipboard

clippingviewport

connect

credentialsrequired

desktopname

disconnect

securityfailure

serververification

Methods

RFB.approveServer()

RFB.blur()

RFB.clipboardPasteFrom()

RFB.disconnect()

RFB.focus()

RFB.getImageData()

RFB.machineReboot()

RFB.machineReset()

RFB.machineShutdown()

RFB.sendCredentials()

RFB.sendCtrlAltDel()

RFB.sendKey()

RFB.toBlob()

RFB.toDataURL()

Details

RFB()

The RFB() constructor returns a new RFB object and initiates a new connection to a specified VNC server.

Syntax
new RFB(target, urlOrChannel);
new RFB(target, urlOrChannel, options);
Parameters

target

urlOrChannel

options Optional

bell

The bell event is fired when the server has requested an audible bell.

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.

clippingviewport

The clippingviewport event is fired whenever RFB.clippingViewport changes between true and false. The detail property is a boolean with the new value of RFB.clippingViewport.

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.

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.

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.

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.

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.

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.

serververification

The serververification event is fired when the server provides information that allows the user to verify that it is the correct server and protect against a man-in-the-middle attack. The detail property is an Object containing the property type which is a DOMString specifying which type of information the server has provided. Other properties are also available, depending on the value of type:

"RSA"

RFB.approveServer()

The RFB.approveServer() method is used to signal that the user has verified the server identity provided in a serververification event and that the connection can continue.

Syntax
RFB.approveServer();

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.clipboardPasteFrom()

The RFB.clipboardPasteFrom() method is used to send clipboard data to the remote server.

Syntax
RFB.clipboardPasteFrom(text);
Parameters

text

RFB.disconnect()

The RFB.disconnect() method is used to disconnect from the currently connected server.

Syntax
RFB.disconnect();

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.focus(options);
Parameters

options Optional

RFB.getImageData()

The RFB.getImageData() method is used to return the current content of the screen encoded as ImageData.

Syntax
RFB.getImageData();

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.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.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

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.sendKey()

The RFB.sendKey() method is used to send a key event to the server.

Syntax
RFB.sendKey(keysym, code);
RFB.sendKey(keysym, code, down);
Parameters

keysym

code

down Optional

RFB.toBlob()

The RFB.toBlob() method is used to return the current content of the screen encoded as Blob.

Syntax
RFB.toBlob(callback);
RFB.toBlob(callback, type);
RFB.toBlob(callback, type, quality);
Parameters

callback

type Optional

quality Optional

RFB.toDataURL()

The RFB.toDataURL() method is used to return the current content of the screen encoded as a data URL that could for example be put in the src attribute of an img tag.

Syntax
RFB.toDataURL();
RFB.toDataURL(type);
RFB.toDataURL(type, encoderOptions);
Parameters

type Optional

encoderOptions Optional