Posts

Showing posts with the label MoSync

Extending HTML5 Mobile Apps with C++ in MoSync

Invoke C++ Code from JavaScript The following example code is based on the HTML5/JS/C++ Hybrid Project Template . This template illustrates how to invoke custom C++ code from JavaScript. The UI has buttons for making the device vibrate and beep. To create a project based on this template, launch MoSync SDK, and create an app in the Eclipse-based IDE, using the HTML5/JS/C++ Hybrid Project template. Then you will get the source code discussed below. The template app uses the Wormhole C++ library (classes HybridMoblet and MessageStream) and the JavaScript libraries included in the file wormhole.js (all included with the application template). Sending String Messages It is good to know that two message formats are supported by Wormhole: JSON messages and String stream messages. The example we discuss here uses String streams. String streams are a performant way of sending messages from JavaScript to C++. This method is generally faster than JSON messages (on some platfor...