Hi All,
  I am trying to call the  JavaScript call back function from the C++
application as mentioned in the attached sample file. But it is crashing
when I am calling from the thread.
In my C++ application I have created a thread which continuously listens on
UDP socket and when data comes I need to intimate to the JavaScript
application. When I am calling the JavaScript call back function from the
C++ application webkit is crashing. Could you please suggest me how can I
call the JS callback function from C++ ?



Thanks in Advance.


Thanks,
Anil.V
int myServerNotification_1(unsigned char *mydata)
{
    JSStringRef jsEmptyIString;
    JSValueRef exception            = 0x00;  
    JSStringRef functionName        = JSStringCreateWithUTF8CString("notificationReceived");
    WebkitWebFrame *frame_myserver = webkit_web_view_get_main_frame (WEBKIT_WEB_VIEW (web_view));
    JSGlobalContextRef jsCtx = webkit_web_frame_get_global_context (frame_myserver);
    JSValueRef jsArgs[2];
    jsArgs[0] = JSValueMakeNumber(jsCtx,3);
    JSValueRef functionValue        = JSObjectGetProperty(jsCtx, JSContextGetGlobalObject(jsCtx), functionName, &exception);
    JSStringRelease(functionName);

    if( exception )
    {
        fprintf(stderr,"\n Exception occured in %s at %d \n",__FILE__,__LINE__);
        return 0;

    }

    jsEmptyIString = JSStringCreateWithUTF8CString((const char *)mydata);
    jsArgs[1] = JSValueMakeString(jsCtx, jsEmptyIString);
    JSStringRelease(jsEmptyIString);

    JSObjectRef jsFunctionObject = JSValueToObject(jsCtx, functionValue, &exception);
    if( exception )
    {
        fprintf(stderr,"\n Excepion occured in %s at %d \n",__FILE__,__LINE__);
        return 0;

    }
   

    JSObjectCallAsFunction(jsCtx,jsFunctionObject, NULL, 2, jsArgs, &exception);
    if(  exception )
    {
        fprintf(stderr,"\n Exception occured while calling the JS CallBack function \n");
        return 0;

    }
   
}


_______________________________________________
webkit-help mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-help

Reply via email to