HTML and CSS Reference
In-Depth Information
In this section, we will focus on RFB client to server message types 4 and 5, keyboard
and mouse events respectively.
Mouse Input
Handling mouse and keyboard input is an important part of our sample implementation
and represents the capturing actions from the keyboard and mouse clicks. These actions
trigger JavaScript events that are sent from the client to the server. This lets VNC users
control applications running on remote systems. In our application, we will detect input
events in JavaScript and send the corresponding RFB protocol messages over our open
WebSocket.
In the RFB protocol, a PointerEvent represents either movement or a pointing
device button press or release. The PointerEvent message is a binary event message
consisting of a message-type byte that specifies what kind of message is being sent to the
server (for example, a pointing device click, a pointing device movement, and so on), a
button-mask byte which carries the current state of the pointing device buttons from 1 to 8
that are represented by the bits 0 to 7 where 0 means the button is up and 1 means the
button is down or pressed, and two position values each consisting of an unsigned short
integer that represents the X and Y coordinates in relation to the screen (see Figure 6-3 ).
Figure 6-3. Pressing the left mouse button generates a binary PointerEvent message of 6 bytes
Listing 6-13 shows the mouse event.
Listing 6-13. Mouse Event
var doMouseEvent = function ($this, e) {
var event = new CompositeStream();
event.appendBytes(5); // type (u8 5)
event.appendBytes($this.buttonMask);
 
Search WWH ::




Custom Search