Commit Graph

35 Commits

Author SHA1 Message Date
Solly Ross b1dee94788 Cleanup: RFB Client
File: rfb.js (also websock.js)
Tests Added: True

Changes:
- De-Crockford-ified rfb.js
- Added methods to websock.js to skip bytes in the receive queue
2014-09-15 16:46:02 -04:00
Solly Ross 2cccf7530c Cleanup: WebSocket Helper
File: websock.js
Tests Added: True
Changes:
- Cleaned up JSHint errors
- Converted to normal JS constructor pattern with "private" fields and
  methods now simply being prepended by underscores
- Added a "bind" polyfill for use in PhantomJS 1.x in util.js
- Added FakeWebSocket to fill in for actual WebSocket objects when
  testing
- Made exception handler actually log exception name and message,
  to console, in addition to stack trace
2014-09-15 16:46:02 -04:00
samhed 960752ea53 fixes an error that was made in the merge with the last sync with websockify. 2014-08-19 13:49:55 +02:00
samhed 082027dc87 Sync with websockify
Pull 90b519edf0c1857d
2014-04-14 14:45:15 +02:00
Dominic Luechinger 97362c3980 Improved websocket binary support detection
A facke connection to 'wss://localhost:17523' (randomly chosen) to detect
the WebSocket binary support is not the best solution.
First of all, check of prototype has the property 'binaryType'. If not,
perform a dummy connection to 'wss://.' instead of 'wss://localhost:17523'.

This patch was inspired by the discussion and implementation of Modernizr:
https://github.com/Modernizr/Modernizr/issues/370
https://github.com/Modernizr/Modernizr/blob/master/feature-detects/websockets/binary.js
2014-03-11 14:29:58 +01:00
jalf ec34af8f61 Use wss when creating localhost connection to detect binary support
Some browsers (Firefox) reject unencrypted ws connections if the hosting
page uses https by throwing an exception when you create the websocket
object.

NoVNC interprets this as binary being unsupported, and falls back to
base64.

If we instead connect to wss://localhost, the websocket object can be
created regardless of whether the hosting page is on http or https.
2013-04-05 13:49:17 +02:00
Joel Martin 705c54edb6 Sync with websockify.
Pull c33f0b52e7 from websockify.

- Fix for python2.4 with URL parsing.
- Set binaryType earlier in Opera 12.10 to avoid receiving a blob.
- Re-order client and target processing so that pending client data
  has an opportunity to be sent when the target closes.
2012-11-14 12:28:22 -05:00
Joel Martin 49578da448 sync with websockify
Pull in websockify 1669139
2012-10-26 18:07:25 -05:00
Joel Martin 35785a9081 Add binary/base64 data mode to perf/playback tests. 2012-10-17 11:58:13 -05:00
Joel Martin 6f4b1e4071 Refactor dynamic script loading. Add util.js:load_scripts()
Related to issue/pulls:
https://github.com/kanaka/noVNC/issues/194
https://github.com/kanaka/noVNC/pull/201
https://github.com/kanaka/noVNC/pull/202

In IE9, the window.onload event can fire before dynamically loaded
scripts have finished loading. This can result in either WebSocket (in
the case of vnc_auto.html) or RFB (in the case of vnc.html) not being
defined at the point when window.onload is called.

- Move the load_scripts routine from vnc.js to util.js (so that
  websockify can use it too). Also, refactor to work when load_scripts
  is called by a script that itself uses load_scripts. When the whole
  chain of dynamically loaded scripts is finished then call
  window.onscriptsload. Use this mechanism in all the places that
  depend on dynamic loading of scripts: vnc.html, vnc_auto.html,
  websock.js, tests/vnc_playback.html, and tests/vnc_perf.html.

- Use the new window.onscriptsload handler instead of window.onload.

- Remove include/start.js and do the script loading and startup event
  handling in include/ui.js instead.
2012-10-17 11:58:12 -05:00
Joel Martin 1d728ace69 Change noVNC license to from LGPLv3 to MPL 2.0
The MPL 2.0 license is a "file-level" copyleft license vs the
"project-level" nature of the L/GPL. The intention of noVNC has
always been that it should be easy to incorporate into existing
projects and sites whether free/open or proprietary/commercial. The MPL
2.0 is designed for this sort of combination project but still
requires that any distributed modifications to noVNC source files must
also be published under the same license.

In addition, the MPL 2.0 allows the code to be used in L/GPL projects
(the secondary license clause). This means that any projects that are
already incorporating noVNC should not be impacted by this change and
in fact it should clarify the licensing situation (the exact
application of the L/GPL to web applications and interpreted code is
somewhat ambiguous).

The HTML, CSS, image and font files continue to be under more
permissive licenses (see LICENSE.txt). The included websockify python
code remains under a LGPLv3 license although the include/websock.js
file from the websockify component is now under MPL 2.0 as well.

Permission was received from other noVNC authors to make this change to their
code license on the following dates:

    - Chris Gordon (UI): Jun 24, 2012
    - Antoine Mercadal (DOM,*util.js): Oct 10, 2012
    - William Lightning (UltraVNC repeater): Oct 10, 2012
    - Mike Tinglof (tight encoding): Oct 15, 2012
2012-10-15 13:35:00 -05:00
Joel Martin 204675c85d Update websockify/websock.js.
This change pulls websockify 6d9deda9c5.

Most note worthy changes:
- Pulls in web-socket-js 7677e7a954 which updates to IETF 6455 (from
  Hixie)
- Binary support detection and use in include/websock.js
- Add ssl and unix target support
- Add multiple target support via config file/dir.
- Idle timeout exit
2012-09-17 17:00:01 -05:00
Joel Martin 3435491edb Merge branch 'binary', fix encode_message
Conflicts:
	include/websock.js

For some reason encode_message was missed. But I'm just punting and
doing the fixup in the merge. Yeah, tsk, tsk.
2012-09-14 17:46:48 -05:00
Joel Martin fcff386b92 websock.js: simpler binary support, protocols param.
Use a simpler method of enabling binary transfer over WebSockets. This
still presents the user of websock.js with a plain javascript array
for the receive queue data. However, if binary support is supported
and requested then the transfer will be raw frames instead of base64
encoded.

Lots of room for optimization here but for now correct is better than
fast.

Pull from websockify 17175afd7311c55abd8d
2012-08-16 13:31:31 -05:00
Joel Martin fc003a13e7 Revert "Pull in latest websockify."
This reverts commit 4dd1bb1ecb.
2012-08-15 13:48:03 -05:00
Joel Martin 4dd1bb1ecb Pull in latest websockify.
Pull in version 376872d99.

Several changes including:
- binary/typed array support in websock.js
- unix socket support
- multiple target support via config file(s)
- prefer IPv6 option
2012-08-14 15:35:48 -05:00
Joel Martin e5d5a7d3fd websock.js: comment out debug options. 2012-06-25 21:42:56 -05:00
Joel Martin d58f8b5144 License clarification: HTML,CSS,images,fonts under permissive licenses.
Clarify in LICENSE.txt that the noVNC core library is the part that is
LGPLv3 licensed. The HTML, CSS, images and fonts are separate from the
core library and can be modified and distributed with the noVNC core
but under their own license conditions.

HTML and CSS: 2-Clause BSD
Fonts: SIL OFL 1.1
Images: CC BY SA 3.0

In other words, you can modify the layout and appearance of of noVNC
to integrate with an existing or new web site or application without
having to publish the source for those modifications under the LGPLv3.
However, use of and modification of the noVNC core library (i.e. the
core Javascript that makes up noVNC) must still be according to the
LGPLv3.

Chris Gordon was the other contributor to the HTML, CSS, and images
included with noVNC and gave permission for this license clarification
on June 23, 2012.
2012-06-24 16:29:44 -05:00
Joel Martin bee36506e1 Fix forcing of web-socket-js even when native available. 2012-06-08 10:42:26 -05:00
Joel Martin ff4bfcb773 Linting.
Switched to using: http://www.jshint.com/
2012-01-12 12:38:55 -06:00
Joel Martin f2d856767d websockify: better multi-python version support.
Pull from websockify: 008a5118e728.

Should address issue https://github.com/kanaka/noVNC/issues/107

- Also add ability to force use of web-socket-js using
  window.WEB_SOCKET_FORCE_FLASH

- in websock.js, for rQshift*, assume length is the full length if not
  specified.
2011-12-15 15:26:16 -06:00
Joel Martin b688a909b0 Show close code and reason.
Also add commented out web-socket-js debug variable in
include/websock.js
2011-12-15 13:59:35 -06:00
Joel Martin ce3bdbccc2 Catch Mozilla prefixing of WebSocket.
Pull 475cfae from websockify.

In Firefox 7 Mozilla has added Websockets support but prefixed the
constructor with "Moz".
2011-08-02 08:02:51 -05:00
Joel Martin 61fc1f2287 Remove extraneous question mark.
Part of https://github.com/kanaka/noVNC/issues/69

Pull from websockify b590289de5.
2011-06-28 16:29:29 -05:00
Joel Martin 0b7bc4e986 Only append random string to swf path in IE.
Issue https://github.com/kanaka/noVNC/issues/69

Thanks https://github.com/EdSchouten for the catch.

Import from websockify 9a2b50d8.
2011-06-28 16:22:50 -05:00
Joel Martin fa8f14d56d Fix playback of recorded VNC.
- Update test mode calls to work with separate websock module.

- Pull in include/websock.js update 7f487fdbd from websockify.
2011-06-26 14:17:42 -05:00
Joel Martin d890e8640f API changes/cleanup.
API changes:
    - include/canvas.js renamed to include/display.js
    - Display.rescale() method removed from API. Use Display.set_scale() instead.
    - Make logo configuration attribute of Display and display it when
      clear() is called if it is set.

API deprecations:
    - use RFB onUpdateState instead of updateState.
    - use RFB onClipboard instead of clipboardReceive.

See https://github.com/kanaka/noVNC/wiki/ModuleAPI for detailed noVNC
modules and API description.

Expand and normalize the event/callback interfaces. Standize on
"onEventName" form for callbacks.

    Callback Renames:
        - RFB updateState -> onUpdateState
        - RFB clipboardReceive -> onClipboard
        - Keyboard keyPress -> onKeyPress
        - Mouse mouseButton -> onMouseButton
        - Mouse mouseMove -> onMouseMove

    Callback Additions:
        - RFB onPasswordRequired
        - RFB onBell
        - RFB onFBUReceive
        - RFB onFBUComplete

Other:
- Add array type support to Util.conf_default()
- Removed a bunch of routines from the Display API that were just used
  internally and not actually by noVNC: flush, setFillColor,
  imageDataGet, imageDataCreate, rgbxImageData, rgbxImageFill,
  cmapImageData, cmapImageFill.
- More keyboard/mouse logging when debug turned on.
- Some JSLinting
2011-05-11 15:55:44 -05:00
Joel Martin f31eeaa8ab Stop sending empty frames.
Pull from websockify a339a4856.
2011-05-09 17:22:02 -05:00
Joel Martin bbd21ca7b5 Update web-socket-js to bb5797cad.
Syncs with same change to websockify (7534574a2f).

Primary change is removal of FABridge interface.

Seems to improve overall latency by perhaps 10%. Also, the slowdown
over time in Opera is about half as bad (but still there).
2011-03-16 10:33:01 -05:00
Joel Martin 43cf7bd83b Some JSLint'ing 2011-02-19 16:44:10 -06:00
Joel Martin 0981845ec4 IE9 fixes. Works but slow. API change.
API change: changed include path variable from VNC_uri_prefix to
URI_INCLUDE since websock.js uses the variable and websock.js is no
longer just for noVNC (i.e. websockify is really the canonical
location for websock.js).

Changes to get web-socket-js to work. Right now it's a hack to get
around: https://github.com/gimite/web-socket-js/issues#issue/41. The
hack is to disable caching of the flash objects by appending
"?" + Math.random() to the end of the flash object path (but only when
using IE).
2011-01-30 22:58:22 -06:00
Joel Martin 7cc5fbc52e Opera 11 WebSockets and Opera '-' key mapping fix.
Opera 11 native WebSockets (if enabled) seems to have bad behavior for
the bufferedAmount so add change from websockify project to allow max
bufferedAmount (before send queue is delay) to be configured.

Also, Opera 11 and 10.60 behave like Mozilla regarding the '-' key so
translate it correctly.
2011-01-23 19:36:11 -06:00
Joel Martin 1756a30a48 websock.send returns true/false.
If all send data was flushed from the send queue then return true,
otherwise false. This doesn't mean the data won't be sent, just that
it wasn't sent this time and is queued.
2011-01-23 19:21:04 -06:00
Joel Martin 8b502df2a1 Tolerate some bufferedAmount.
Only delay sending data if bufferedAmount is greater than 1000.

This seems to match the intention of the spec better. bufferedAmount
does not mean that we can't send, it's just an indication that the
network is becoming saturated. But Opera 11 native WebSockets seems to
have a bug that bufferedAmount isn't set back to zero correctly so
we'll be a bit more tolerant.
2011-01-23 19:17:59 -06:00
Joel Martin 72f1348b35 Convert to Websock library.
Copy in include/websock.js from websockify and use that instead. Still
some cleanup of network code but it's a good start.
2011-01-13 00:30:08 -06:00