javascript - NativeClient : How to use Messaging_HandleMessage in C -
i've got problem c code , lack of informations nacl in c painful... use earth example .png loaded javascript , send c module when message don't know how convert ppb_vardictionary, got idea ?
here c method :
static void messaging_handlemessage(pp_instance instance, struct pp_var message) { fprintf(stdout, "%i\n", message.type); if(message.type == pp_vartype_dictionary) { ppb_vardictionary *dictionary = null; dictionary->create(); } }
thanks in advance reply.
unlike c++, can pass pp_var
ppb_vardictionary
interface directly. if correct type, work. if not, give error.
you can take @ nacl_io_demo example (examples/demo/nacl_io in nacl sdk) see how works. in case, can this:
ppb_var* g_ppb_var = null; ppb_vardictionary* g_ppb_var_dictionary = null; pp_export int32_t ppp_initializemodule(pp_module a_module_id, ppb_getinterface get_browser) { g_ppb_var = (ppb_var*)(get_browser(ppb_var_interface)); g_ppb_var_dictionary = (ppb_vardictionary*)(get_browser(ppb_var_dictionary_interface)); return pp_ok; } static void messaging_handlemessage(pp_instance instance, struct pp_var message) { fprintf(stdout, "%i\n", message.type); if(message.type == pp_vartype_dictionary) { // value maps key "foo". pp_var key_var = g_ppb_var->varfromutf8("foo", 3); pp_var value_var = g_ppb_var_dictionary->get(message, key_var); g_ppb_var->release(key_var); // value_var... } }
Comments
Post a Comment