HTML and CSS Reference
source VNC server using RFB over WebSocket. We'll walk through techniques used to
enable screen sharing (a typical use case for VNC) over WebSocket and examine how to
enable remote device input from a keyboard and mouse. Sound complex? RFB is indeed a
more complex protocol than XMPP and STOMP.
The code examples that accompany this topic contain the full, end-to-end RFB
over WebSocket application that you can run against a VNC server. But, if you do not
wish to work through the complexities of RFB, you can follow the steps in this chapter by
referring to the Virtual Machine (VM) we provided (see Appendix B for instructions). The
VM contains working code that you can run, examine, and digest at will. In the hands-on
portion of this chapter, we'll highlight the code snippets in our application that are
specifically pertinent to WebSocket and techniques for building an RFB over WebSocket
client. After you explore the ideas in this chapter at a high level, you can run the code
yourself and see how it all works together. Then, to analyze the code more closely, you
can open the code examples in the VM.
The layering of RFB over WebSocket may not be for the fainthearted, but this
compelling example contrasts to some of the more common WebSocket use cases like
chat, as it illustrates the more interactive and graphical capabilities you can implement
using HTML5 and WebSocket. Additionally, it shows how WebSocket can help bridge
HTML5 and legacy systems.
Not ■ The VNC over webSocket demo we use in this chapter was originally developed by
Kaazing in 2010 to showcase webSocket technology.
An Overview of Virtual Network Computing
The desktop metaphor for computing has been extremely popular for several decades.
Historically, popular desktop operating systems have had networked windowing systems
and remote access protocols that enabled the use of their systems from terminals
and other PCs. Over the past few decades, the rise of the personal computer has also
stimulated an explosion of desktop applications. Most of these desktop applications
are now legacy applications, and not all of these legacy applications have comparable
alternatives. VNC is a standard way to give users and systems the ability to continue
to access legacy applications and systems, without concern for operating system
compatibility. VNC also enables you to remotely interact with systems and applications
on another computer as though you are actually using that computer.
Figure 6-1 shows a desktop controlling another computer's mouse and keyboard
over the Web. The pixels of the remote display are duplicated on the controlling machine.
Figure 6-1. Accessing the desktop of another PC over the Internet