Пример #1
0
	/**
	 * Calls a JavaScript callback function using the "callbackId"
	 * parameter. The callbackId is supplied automatically when
	 * calling mosync.bridge.send wuth a callback function.
	 * @param message The message stream from which to get the
	 * callback id.
	 * @param result A string that contains the data to be returned
	 * to the JavaScript callback function.
	 * @param success Success value passed back to JavaScript, used
	 * to indicate success or error of a call.
	 */
	void callCallbackWithResult(
		Wormhole::MessageStream& message,
		const String& result,
		bool success)
	{
		// Get the callbackID parameter.
		const char* callbackId = message.getNext();

		// Call JavaScript reply handler.
		String successValue = success ? "true" : "false";
		String script = "mosync.bridge.reply(";
		script += callbackId;
		script += ",'" + result + "'";
		script += "," + successValue + ")";

		lprintfln("@@@ JS: %s", script.c_str());

		message.getWebView()->callJS(script);
	}