This is a mirror of official site: http://jasper-net.blogspot.com/

Native Client SDK

| Sunday, August 21, 2011
Contents

  1. Basics
  2. Step 1: Download and install the Native Client SDK.
  3. Step 2: Download and install Python if necessary.
  4. Step 3: Start a local server.
  5. Step 4: Set up Chrome and verify that Native Client is working.
  6. Step 5: Create a set of template files for your project.
  7. Step 6: Modify the web page to load and communicate with the Native Client module.
  8. Step 7: Implement a message handler in the Native Client module.
  9. Step 8: Compile the Native Client module.
  10. Step 9: Try it out.
  11. Troubleshooting
  12. Next steps

Basics

This tutorial shows you how to create, compile, and run a Native Client web application. The Native Client module you will create as part of the web app will be written in C++.

A Native Client web app consists of at least three entities:

    The HTML web page (*.html). The page can also contain JavaScript code and CSS styles, or the scripting and styling code can go in separate .js and .css files.
    A Native Client module, written in C or C++. Native Client modules uses the Pepper API, included in the SDK, as a bridge between the browser and the modules. When compiled, the extension for a Native Client module is .nexe.
    A manifest file (*.nmf) that is used by the browser to determine which compiled Native Client module to load for a given end-user instruction set ("x86-64" or "x86-32").

What the app in this tutorial does

This example shows how to load a Native Client module from a web page and how to send messages between JavaScript and the Native Client module. In this simple app, the JavaScript in the web page sends a "hello" message to the Native Client module. When the Native Client module receives a message, it checks whether the message is equal to the string "hello." If it is, the Native Client module returns a message saying "hello from NaCl." A JavaScript alert displays the message received from the Native Client module.

This tutorial uses a Python script to create a set of template files that you can use as a starting point. The template code shows how to set up a simple message handler on the Native Client side. It also provides boilerplate code in the HTML file for adding an event listener to the web page to receive messages from the Native Client module.
Communication between JavaScript and a Native Client module

Communication between JavaScript code in the browser and C++ code in a Native Client module is two-way: the browser can send messages to the Native Client module. The Native Client module can respond to the message from JavaScript, or it can initiate its own message to JavaScript. In all cases, the communication is asynchronous. A message is sent, but the system does not wait for a response. This behavior is analogous to client/server web communication, where the client posts a message to the server and returns immediately.

Read more: Google code
QR: tutorial.html

Posted via email from Jasper-net

0 comments: