来自FireBreath的回调

Callback from FireBreath

本文关键字:回调 FireBreath 来自      更新时间:2023-09-26

在我的插件,我想开始一个新的线程,并从它的回调:

我有

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?
  }
}

答案是真的吗?从插件到浏览器/html-page的异步回调是真的吗?

也许,我解决了问题。

我不使用InvokeAsync,我使'signal':

FB_JSAPI_EVENT(event1, 0, ());

那么我发出'信号'

fire_event1();

和我在现场收到'信号'

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

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