3 The interface of the noVNC client consists of a single RFB object that
4 is instantiated once per connection.
8 The `RFB` object represents a single connection to a VNC server. It
9 communicates using a WebSocket that must provide a standard RFB
15 - Creates and returns a new `RFB` object.
20 - Is a `boolean` indicating if any events (e.g. key presses or mouse
21 movement) should be prevented from being sent to the server.
25 - Is a `boolean` indicating if keyboard focus should automatically be
26 moved to the canvas when a `mousedown` or `touchstart` event is
30 - Is a `long` controlling the button mask that should be simulated
31 when a touch event is recieved. Uses the same values as
32 [`MouseEvent.button`](https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/button).
33 Is set to `1` by default.
36 - Is a `double` indicating how the framebuffer contents should be
37 scaled before being rendered on to the canvas. See also
38 [`RFB.autoscale()`](#rfbautoscale). Is set to `1.0` by default.
41 - Is a `boolean` indicating if the canvas should be clipped to its
42 container. When disabled the container must be able to handle the
43 resulting overflow. Disabled by default.
46 - Is a `boolean` indicating if mouse events should control the
47 relative position of a clipped canvas. Only relevant if
48 `clipViewport` is enabled. Disabled by default.
50 `isClipped` *Read only*
51 - Is a `boolean` indicating if the framebuffer is larger than the
52 current canvas, i.e. it is being clipped.
54 `capabilities` *Read only*
55 - Is an `Object` indicating which optional extensions are available
56 on the server. Some methods may only be called if the corresponding
57 capability is set. The following capabilities are defined:
59 | name | type | description
60 | -------- | --------- | -----------
61 | `power` | `boolean` | Machine power control is available
62 | `resize` | `boolean` | The framebuffer can be resized
67 - The `connect` event is fired when the `RFB` object has completed
68 the connection and handshaking with the server.
70 [`disconnect`](#disconnected)
71 - The `disconnect` event is fired when the `RFB` object disconnects.
73 [`credentialsrequired`](#credentialsrequired)
74 - The `credentialsrequired` event is fired when more credentials must
77 [`clipboard`](#clipboard)
78 - The `clipboard` event is fired when clipboard data is received from
82 - The `bell` event is fired when a audible bell request is received
85 [`fbresize`](#fbresize)
86 - The `fbresize` event is fired when the framebuffer size is changed.
88 [`desktopname`](#desktopname)
89 - The `desktopname` event is fired when the remote desktop name
92 [`capabilities`](#capabilities)
93 - The `capabilities` event is fired when `RFB.capabilities` is
98 [`RFB.disconnect()`](#rfbdisconnect)
99 - Disconnect from the server.
101 [`RFB.sendCredentials()`](#rfbsendcredentials)
102 - Send credentials to server. Should be called after the
103 [`credentialsrequired`](#credentialsrequired) event has fired.
105 [`RFB.sendKey()`](#rfbsendKey)
108 [`RFB.sendCtrlAltDel()`](#rfbsendctrlaltdel)
109 - Send Ctrl-Alt-Del key sequence.
111 [`RFB.machineShutdown()`](#rfbmachineshutdown)
112 - Request a shutdown of the remote machine.
114 [`RFB.machineReboot()`](#rfbmachinereboot)
115 - Request a reboot of the remote machine.
117 [`RFB.machineReset()`](#rfbmachinereset)
118 - Request a reset of the remote machine.
120 [`RFB.clipboardPasteFrom()`](#rfbclipboardPasteFrom)
121 - Send clipboard contents to server.
123 [`RFB.autoscale()`](#rfbautoscale)
124 - Set `RFB.viewportScale` so that the framebuffer fits a specified
127 [`RFB.requestDesktopSize()`](#rfbrequestDesktopSize)
128 - Send a request to change the remote desktop size.
130 [`RFB.viewportChangeSize()`](#rfbviewportChangeSize)
131 - Change size of the viewport.
137 The `RFB()` constructor returns a new `RFB` object and initiates a new
138 connection to a specified VNC server.
142 var rfb = new RFB( target, url [, options] );
147 - A [`HTMLCanvasElement`](https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement)
148 that specifies where graphics should be rendered and input events
152 - A `DOMString` specifying the VNC server to connect to. This must be
153 a valid WebSocket URL.
155 **`options`** *Optional*
156 - An `Object` specifying extra details about how the connection
162 - A `boolean` indicating if the remote server should be shared or
163 if any other connected clients should be disconnected. Enabled
167 - An `Object` specifying the credentials to provide to the server
168 when authenticating. The following credentials are possible:
170 | name | type | description
171 | ------------ | ----------- | -----------
172 | `"username"` | `DOMString` | The user that authenticates
173 | `"password"` | `DOMString` | Password for the user
174 | `"target"` | `DOMString` | Target machine or session
177 - A `DOMString` specifying the ID to provide to any VNC repeater
182 The `connect` event is fired after all the handshaking with the server
183 is completed and the connection is fully established. After this event
184 the `RFB` object is ready to recieve graphics updates and to send input.
188 The `disconnect` event is fired when the connection has been
189 terminated. The `detail` property is an `Object` the optionally
190 contains the property `reason`. `reason` is a `DOMString` specifying
191 the reason in the event of an unexpected termination. `reason` will be
192 omitted for a clean termination.
194 #### credentialsrequired
196 The `credentialsrequired` event is fired when the server requests more
197 credentials than were specified to [`RFB()`](#rfb-1). The `detail`
198 property is an `Object` containing the property `types` which is an
199 `Array` of `DOMString` listing the credentials that are required.
203 The `clipboard` event is fired when the server has sent clipboard data.
204 The `detail` property is an `Object` containing the property `text`
205 which is a `DOMString` with the clipboard data.
209 The `bell` event is fired when the server has requested an audible
214 The `fbresize` event is fired when the framebuffer has changed
215 dimensions. The `detail` property is an `Object` with the properties
216 `width` and `height` specifying the new dimensions.
220 The `desktopname` event is fired when the name of the remote desktop
221 changes. The `detail` property is an `Object` with the property `name`
222 which is a `DOMString` specifying the new name.
226 The `capabilities` event is fired whenever an entry is added or removed
227 from `RFB.capabilities`. The `detail` property is an `Object` with the
228 property `capabilities` containing the new value of `RFB.capabilities`.
230 #### RFB.disconnect()
232 The `RFB.disconnect()` method is used to disconnect from the currently
239 #### RFB.sendCredentials()
241 The `RFB.sendCredentials()` method is used to provide the missing
242 credentials after a `credentialsrequired` event has been fired.
246 RFB.sendCredentials( credentials );
251 - An `Object` specifying the credentials to provide to the server
252 when authenticating. See [`RFB()`](#rfb-1) for details.
256 The `RFB.sendKey()` method is used to send a key event to the server.
260 RFB.sendKey( keysym, code [, down] );
265 - A `long` specifying the RFB keysym to send. Can be `0` if a valid
266 **`code`** is specified.
269 - A `DOMString` specifying the physical key to send. Valid values are
270 those that can be specified to
271 [`KeyboardEvent.code`](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/code).
272 If the physical key cannot be determined then `null` shall be
275 **`down`** *Optional*
276 - A `boolean` specifying if a press or a release event should be
277 sent. If omitted then both a press and release event are sent.
279 #### RFB.sendCtrlAltDel()
281 The `RFB.sendCtrlAltDel()` method is used to send the key sequence
282 *left Control*, *left Alt*, *Delete*. This is a convenience wrapper
283 around [`RFB.sendKey()`](#rfbsendkey).
287 RFB.sendCtrlAltDel( );
289 #### RFB.machineShutdown()
291 The `RFB.machineShutdown()` method is used to request to shut down the
292 remote machine. The capability `power` must be set for this method to
297 RFB.machineShutdown( );
299 #### RFB.machineReboot()
301 The `RFB.machineReboot()` method is used to request a clean reboot of
302 the remote machine. The capability `power` must be set for this method
307 RFB.machineReboot( );
309 #### RFB.machineReset()
311 The `RFB.machineReset()` method is used to request a forced reset of
312 the remote machine. The capability `power` must be set for this method
319 #### RFB.clipboardPasteFrom()
321 The `RFB.clipboardPasteFrom()` method is used to send clipboard data
322 to the remote server.
326 RFB.clipboardPasteFrom( text );
331 - A `DOMString` specifying the clipboard data to send. Currently only
332 characters from ISO 8859-1 are supported.
336 The `RFB.autoscale()` method is used to automatically adjust
337 `RFB.viewportScale` to fit given dimensions.
341 RFB.autoscale( width, height );
346 - A `long` specifying the maximum width of the canvas in CSS pixels.
349 - A `long` specifying the maximum height of the canvas in CSS pixels.
351 #### RFB.requestDesktopSize()
353 The `RFB.requestDesktopSize()` method is used to request a change of
354 the framebuffer. The capability `resize` must be set for this method to
357 Note that this is merely a request and the server may deny it.
358 The [`fbresize`](#fbresize) event will be fired when the framebuffer
359 actually changes dimensions.
363 RFB.requestDesktopSize( width, height );
368 - A `long` specifying the new requested width in CSS pixels.
371 - A `long` specifying the new requested height in CSS pixels.
373 #### RFB.viewportChangeSize()
375 The `RFB.viewportChangeSize()` method is used to change the size of the
376 canvas rather than the underlying framebuffer.
378 This method has no effect if `RFB.clipViewport` is set to `false`.
382 RFB.viewportChangeSize( width, height );
387 - A `long` specifying the new width in CSS pixels.
390 - A `long` specifying the new height in CSS pixels.