来自FireBreath的回调

时间:2013-04-23 10:00:48

标签: javascript callback npapi firebreath

在我的插件中,我想启动新线程并从中获取回调:

我有

function myCallback()

我想从插件中的线程每2秒调用一次。

我该怎么做?

// this method calls from html-page:
void MyFirstPluginAPI::testEvent()
{
  //fire_test();
  // thread starting:
  boost::thread my_thread(boost::bind(&MyFirstPluginAPI::hello_world, this));
}
void MyFirstPluginAPI::hello_world() 
{
  for(;;)
  {
    boost::posix_time::seconds SleepTime(2);
    boost::this_thread::sleep(SleepTime);
    // here i must call InvokeAsync("myCallback",FB::variant_list_of(0));
    // how can i to do it?
  }
}

非常感谢。

1 个答案:

答案 0 :(得分:0)

这是真的答案吗?这是从插件到浏览器/ html页面的真正异步回调吗?

也许,我解决了这个问题。

我不使用 InvokeAsync ,我制作'信号':

FB_JSAPI_EVENT(event1, 0, ());

然后我发出'信号'

fire_event1();

我在网站上收到'信号'

addEvent(plugin(), 'event1', function(){
  elem = document.getElementById('mydiv');
  elem.innerHTML = elem.innerHTML + "hello<br>";
});

我会随时测试这个,然后我会将这个问题标记为已解决。

相关问题