Commit Graph

61 Commits

Author SHA1 Message Date
Joel Martin af183e63f5 update failed state on WS onerror.
Also, slightly faster non-base64 (UTF-8) decode.
2010-06-08 11:20:03 -05:00
Joel Martin 14355cb212 Give better exception feedback in message handler. 2010-06-04 13:51:21 -05:00
Joel Martin 913083993b Direct example. Move all DOM code default_controls.js.
Move DOM manipulation into include/default_controls.js and update
vnc.html to use it.

Add an example vnc_auto.html which automatically connects using
parameters from the query string and doesn't use default_controls.js.

Reorder functions in vnc.js to put external interface functions at the
top of the RFB namespace.
2010-06-02 17:08:25 -05:00
Joel Martin d41c33e4b7 Add colour map support (non-true-color).
In colourMap mode there are 256 colours in a colour palette sent from
the server via the SetColourMapEntries message. This reduces the
bandwidth by about 1/4. However, appearance can be somewhat less than
ideal (pinks instead of gray, etc).

It also increases client side rendering performance especially on
firefox. Rendering a full 800x600 update takes about 950ms in
firefox on my system compared to about 1400ms. Round-trip time for
a full frame buffer update is even better on firefox (due to
performance of the flash WebSocket emulator). Reduced from about
1800ms to 1100ms on firefox (for 800x600 full update).
2010-06-01 14:34:27 -05:00
Joel Martin 507b473a2e Test non-base64 (straight UTF-8) encoding.
Also add a wsencoding test client/server program to test send a set of
values between client and server and vice-versa to test encodings.

Not turned on by default.

Add support for encode/decode of UTF-8 in the proxy. This leverages
the browser for decoding the WebSocket stream directly instead of
doing base64 decode in the browser itself.

Unfortunately, in Chrome this has negligible impact (round-trip time
is increased slightly likely due to extra python processing).

In firefox, due to the use of the flash WebSocket emulator the
performance is even worse. This is because it's really annoying to get
the flash WebSocket emulator to properly decode a UTF-8 bytestream.
The problem is that the readUTFBytes and readMultiByte methods of an
ActionScript ByteArray don't treat 0x00 correctly. They return
a string that ends at the first 0x00, but the index into the ByteArray
has been advanced by however much you requested.

This is very silly for two reasons: ActionScript (and Javascript)
strings can contain 0x00 (they are not null terminated) and second,
UTF-8 can legitimately contain 0x00 values. Since UTF-8 is not
constant width there isn't a great way to determine if those methods
in fact did encounter a 0x00 or they just read the number of bytes
requested.

Doing manual decoding using readUTFByte one character at a time slows
things down quite a bit. And to top it all off, those methods don't
support the alternate UTF-8 encoding for 0x00 ("\xc0\x80"). They also
just treat that encoding as the end of string too.

So to get around this, for now I'm encoding zero as 256 ("\xc4\x80")
and then doing mod 256 in Javascript. Still doesn't result in much
benefit in firefox.

But, it's an interesting approach that could use some more exploration
so I'm leaving in the code in both places.
2010-05-28 15:39:38 -05:00
Joel Martin c3996e24f5 Round-trip timing for first full FBU. 2010-05-28 15:35:10 -05:00
Joel Martin af6b17ce06 Change license to LGPL-3 and add some implementation notes.
The purpose of the code is to be incorporated into other web projects
(whether those are free or not). AGPL prevents combination with other
HTML and javascript that is under a weaker (or proprietary) license.
Better would be a lesser AGPL, but there is not GNU standard for that.
So LGPL-3 meets most of my requirements. If somebody modifies the
actual client code and conveys it, then they must release the changes
under LGPL-3 also.

Add some implementation notes in docs/notes.
2010-05-26 15:43:00 -05:00
Joel Martin a575a383fb Add mouse wheel support and input test page. 2010-05-25 11:05:55 -05:00
Joel Martin 7f4f41b0c7 Don't shift off subencoding in hextile. 2010-05-20 17:13:59 -05:00
Joel Martin 8fe2c2f915 Fix web-socket-js loading issue. 2010-05-17 17:11:13 -05:00
Joel Martin 97763d0eb8 Double Chrome hextile perf again. Add canvas test.
- By dereferencing the 'data' field of the imageData object before the
  loop, the hextile performance on Chrome is down to 140ms or so for
  a full 800x600 update. Still have to fall back to Canvas operations
  for firefox.

- Fix RQ empty after reorder bug.
2010-05-17 13:07:53 -05:00
Joel Martin 3c1bead9a0 Add styling classes for status line state. 2010-05-16 19:58:51 -05:00
Joel Martin f9583f1f98 Move canvas.js to include/canvas.js. 2010-05-15 15:45:09 -05:00
Joel Martin 67b24a9020 Support 3.7. 2010-05-15 15:25:10 -05:00
Joel Martin 56ec48bec8 Move vars into RFB namespace. Extend array in util.js. 2010-05-15 14:55:33 -05:00
Joel Martin c4164bda1d JSLint and "use strict". 2010-05-15 14:28:55 -05:00
Joel Martin 753bde8f53 Cleanup output, trap exceptions, timing output, fixes.
Fixes:
- Make sure that failed state messages stay around until next connect.
- Get status message font colors working.
- Clear RQ_reorder list on re-connect.
2010-05-15 12:38:50 -05:00
Joel Martin 3875f847f1 Double hextile rendering performance in Chrome.
- For webkit engines, do array manipulation for each tile subrectangle
  and only use the array for putImageData after rendering is finished.

In Chrome 5.0.375.29 beta, the time to render a full 800x600 hextile
image dropped from 500ms to 250ms or so. Firefox 3.5.3 rendering of
a full 800x600 hextile image is about 2300ms.
2010-05-15 12:27:44 -05:00
Joel Martin 71d2426a8e Rename HTML5-VNC to noVNC. 2010-05-12 09:39:38 -05:00
Joel Martin db504ade0c Isolate DOM references in load() and connect().
- Other misc cleanups.
2010-05-11 16:39:17 -05:00
Joel Martin ded9dfae10 Styling/integration refactoring.
- Instead of onload override, move to RFB.load function that takes
  a parameter for the target DOM ID. This allows the user to have
  their own onload function.

- Add "VNC_" prefix to all element ID names. Only create DOM elements
  if they don't already exist on the page, otherwise use the existing
  elements.

- Move all styling to separate stylesheet.

- Use list model for control styling.
2010-05-11 16:13:52 -05:00
Joel Martin 4ce2696d52 Merge branch 'merge_kevinykchan'
Conflicts:
	wsproxy.py

Fix auth mode selection typo.
2010-05-11 09:23:55 -05:00
Kevin Chan 2cec49d439 If no password is provided, defaults to use no auth 2010-05-11 21:59:59 +08:00
Joel Martin 97bfe5ba25 Move controls to vnc.js, make vnc.html very simple. 2010-05-06 17:08:53 -05:00
Joel Martin c539e4dcda DES that works with KVM's VNC. RFB 3.8 fixes. 2010-05-05 15:40:05 -05:00
Joel Martin ef764d3b9b Support for RFB 3.8 handshake. 2010-05-02 14:19:13 -05:00
Joel Martin adfe6ac166 Support for SSL/TLS ('wss://') on both sides.
On the client side, this adds the as3crypto library to web-socket-js
so that the WebSocket 'wss://' scheme is supported which is WebSocket
over SSL/TLS.

Couple of downsides to the fall-back method:

    - This balloons the size of the web-socket-js object from about 12K to 172K.

    - Getting it working required disabling RFC2718 web proxy support
      in web-socket-js.

    - It makes the web-socket-js fallback even slower with the
      encryption overhead.

The server side (wsproxy.py) uses python SSL support. The proxy
automatically detects the type of incoming connection whether flash
policy request, SSL/TLS handshake ('wss://') or plain socket
('ws://').

Also added a check-box to the web page to enable/disabled 'wss://'
encryption.
2010-04-30 16:41:09 -05:00
Joel Martin 7b99f70bd0 Don't erase failed state error messages on disconnect. 2010-04-19 10:46:48 -05:00
Joel Martin 07287cfd89 Send seq nums and b64 encode based on query string.
Query string variable 'b64encode' determine if wsproxy b64 encodes the
results. Variable 'seq_num' determines if sequence numbers are
prepended. This way, sequence numbers are only used with the flash
WebSocket proxy.
2010-04-18 20:35:43 -05:00
Joel Martin 8759ea6f90 Status/error refactor. Fix firefox bugs.
- All state/status updates go through updateState routine which
  updates the status line also.

- Old firefox (and opera) don't support canvas createImageData, so use
  getImageData as replacement.

- Add console.warn and console.error stubs so that firefox without
  firebug doesn't crap out.

- If no WebSockets then error if no flash or if URL is location (flash
  will refuse to load the object for security reasons).
2010-04-18 18:43:03 -05:00
Joel Martin 5d8e7ec068 Add web-socket-js support with packet re-ordering.
- web-socket-js is from http://github.com/gimite/web-socket-js. It is
  a flash object that emultates WebSockets.

Unfortunately, events (or packets) from the web-socket-js object can
get re-ordered so we need to know the packet order.

- So wsproxy.py prepends the sequence number of the packet when
  sending.

- If the client receives packets out of order it queues them up and
  scans the queue for the sequence number it's looking for until
  things are back on track. Gross, but hey: It works!

- Also, add packet sequence checking to wstest.*
2010-04-17 17:24:14 -05:00
Joel Martin 5d2c386400 Reassemble partial client packets in wsproxy.py 2010-04-16 16:34:19 -05:00
Joel Martin b5537b60b0 Switch to MPL/GPL base64 from Mozilla.
- Also slightly better performance.
2010-04-15 11:01:40 -05:00
Joel Martin 1a623f7502 Update TODO and small perf cleanups. 2010-04-15 10:16:30 -05:00
Joel Martin 30059bdf24 Add cut and paste support.
- A textarea below the VNC area represents the state of the current
  VNC clipboard. If there is a server cut event, the textarea will be
  updated. If the user updates the contents of the textarea, the new
  data will be sent as a client paste (cut) event.

- One important change was to detect if the clipboard is focused and
  allow the user to type in the clipboard instead of in the VNC area.
2010-04-15 01:40:03 -05:00
Joel Martin 1098b5bf01 Refactor FBU.bytes handling to simplify.
- raw encoding displays horizontal lines as they arrive for better
  feedback and less time hanging waiting for something.
2010-04-14 23:41:12 -05:00
Joel Martin 8cf206154c Working VNC client! Add mouse movement support.
- Mouse movements are accumulated and sent about 5 times a second.
- Normal polling happens at about 1.5 seconds intervals.

This commit represents a very functional VNC client under Google
Chrome.

Remaining work:

    - Cut and paste support.

    - Framing bugs when using RRE encoding.

    - Better status and error feedback.

    - Get working in firefox using flash web-socket-js:
        http://github.com/gimite/web-socket-js

    - Version without mootools (but test cross-browser).
2010-04-14 12:44:47 -05:00
Joel Martin 48ebcdb110 Rename canvas.js routines to not have "rfb" prefix.
- Also, try making set fillStyle called less often.
2010-04-14 12:22:47 -05:00
Joel Martin 31af85b996 Don't clear canvas if debug mode 2010-04-14 12:13:59 -05:00
Joel Martin 28a5f29357 Re-order routines, no functional changes. 2010-04-14 12:10:23 -05:00
Joel Martin fb99d81ccc Better hextile performance: index subrects instead of slicing/shifting.
- Many times better performance. Before this, browser was spending all
  it's time garbage collecting or doing something. Now the bottleneck
  is in set fillStyle and fillRect which is probably where it should
  be.
2010-04-14 12:03:01 -05:00
Joel Martin 410960bac8 Fix some framing bugs. Cleanup console logs. 2010-04-14 11:28:29 -05:00
Joel Martin 484a4696aa Refactor data processing. Ignore other server messages.
- Refactor to pull off all the data received into RFB.d array and then
  process it. This allows a bit more flexibility in handling
  data that isn't sent in frame boundary packets.

- Properly ignore these server messages: SetColourMapEntries, Bell,
  ServerCutText.
2010-04-14 09:48:46 -05:00
Joel Martin d064769ccf Initial mouse support. Down and Up only. 2010-04-13 17:39:01 -05:00
Joel Martin 9f4af5a722 Hextile working. Improve latency by coallescing sends.
- Hextile has an undocumented weirdness where RAW frames are often
  followed by a 0 byte that should be ignored.

- Coallesce client messages that are one after another. Without
  this the server seems to often ignore frames that are send right
  after another frame has been sent. This fixes a reconnect issue
  where setEncodings seems to be ignored. Also results in a huge
  performance increase after key strokes (by adding a update request
  to the key event message) because the server always sends an update
  instead of sometimes waiting for the next poll to be sent.
2010-04-13 12:59:11 -05:00
Joel Martin b7ec54870a Switch to much faster console.log and separate utils into util.js. 2010-04-13 09:28:53 -05:00
Joel Martin 0f62806499 Refactor processing to allow hextile processing.
With hextile you can't know how many bytes are pending. So restructure
so that all the received data so far is passed to the processsing
routines.
2010-04-12 13:21:44 -05:00
Joel Martin f761808540 Process RRE in chunks instead of 1 at a time. 2010-04-12 11:46:43 -05:00
Joel Martin cf67217cbf Change to RGB ordering. 2010-04-12 11:21:03 -05:00
Joel Martin 6dab56f914 Working RRE implementation. 2010-04-12 11:08:40 -05:00