HTML and CSS Reference
In-Depth Information
Listing 6-12. The copyRect() Function
$prototype.copyRect = function copyRect(width, height, xPos, yPos, xSrc, ySrc){
// get pixel data from the current framebuffer
var imageData = this.context.getImageData(xSrc, ySrc, width, height);
// put pixel data in target region
this.context.putImageData(imageData, xPos, yPos);
Other Encodings and Efficiency
While sending raw pixels over the Internet is very inefficient, copyRect is extremely
efficient when you are lucky enough to have repeated pixel values in your framebuffer. Real
desktops are more complex than this, so there are more advanced encodings that can be
used to reduce bandwidth usage of RFB. These encodings use compression algorithms to
reduce the bandwidth required to send pixel data. For example, encoding 16 (0x10) uses
ZLIB for compression. This is the style of encoding you would ideally like to use in a real
RFB-based application. Most RFB clients and servers support compressed updates.
Handling Input in the Client
So far we've built enough of an RFB client to be able to observe a desktop updating in real
time (in effect, screen sharing). In order to interact with that desktop, we need to handle
user input, which will allow the RFB client to control the mouse and keyboard of the RFB
server. In this section, we examine how to accept the mouse and keyboard input on the
client and communicate that input information to the RFB server.
Client to Server Messages
The RFB protocol defines types of messages that the client sends to the server. These
message types indicate what kind of message the client sends to the server. As previously
described, the message type is the first byte of the client to server message and is
represented by an integer. Table 6-1 describes what kinds of message types exist in the
RFB specification.
Table 6-1. Message Types in the RFB Specification
Message Type Number
Message Type
SetPixelFormat
0
SetEncodings
2
FramebufferUpdateRequest
3
KeyEvent
4
PointerEvent
5
ClientCutText
6
 
 
Search WWH ::




Custom Search