示例#1
0
void NotifySignal (uv_work_t *r) {
  v8::HandleScope scope;
  async_req_signal *req = reinterpret_cast<async_req_signal *>(r->data);
  v8::TryCatch try_catch;
  v8::Local<v8::Value> argv[3];
  // Create a new empty array.
  v8::Local<v8::Array> array = v8::Array::New(req->params.size ());
  // // Return an empty result if there was an error creating the array.
  //   if (array.IsEmpty())
  //     return Handle<Array>();
  std::vector <std::string>::iterator it;
  for (it = req->params.begin (); it != req->params.end (); it++)
    array->Set(0, v8::String::New(it->c_str ()));

  argv[0] = { v8::Local<v8::Value>::New(v8::String::New(req->quiddity_name.c_str ())) };
  argv[1] = { v8::Local<v8::Value>::New(v8::String::New(req->signal_name.c_str ())) };
  argv[2] = { v8::Local<v8::Value>::New(array)};
  
  
  if (!user_signal_cb.IsEmpty ())
    if (user_signal_cb->IsCallable ())
      user_signal_cb->Call(user_signal_cb, 3, argv);
  delete req;
  if (try_catch.HasCaught()) {
    node::FatalException(try_catch);
  }
}
示例#2
0
void NotifyLog (uv_work_t *r) {
  v8::HandleScope scope;
  async_req_log *req = reinterpret_cast<async_req_log *>(r->data);
  v8::TryCatch try_catch;
  v8::Local<v8::Value> argv[] = { v8::Local<v8::Value>::New(v8::String::New(req->msg.c_str ())) };
  if (!user_log_cb.IsEmpty ())
    if (user_log_cb->IsCallable ())
      user_log_cb->Call(user_log_cb, 1, argv);
  delete req;
  if (try_catch.HasCaught()) {
    node::FatalException(try_catch);
  }
}
示例#3
0
void NotifyProp (uv_work_t *r) {
  v8::HandleScope scope;
  async_req_prop *req = reinterpret_cast<async_req_prop *>(r->data);
  v8::TryCatch try_catch;
  v8::Local<v8::Value> argv[3];
  argv[0] = { v8::Local<v8::Value>::New(v8::String::New(req->quiddity_name.c_str ())) };
  argv[1] = { v8::Local<v8::Value>::New(v8::String::New(req->property_name.c_str ())) };
  argv[2] = { v8::Local<v8::Value>::New(v8::String::New(req->value.c_str ())) };
  if (!user_prop_cb.IsEmpty ())
    if (user_prop_cb->IsCallable ())
      user_prop_cb->Call(user_prop_cb, 3, argv);
  delete req;
  if (try_catch.HasCaught()) {
    node::FatalException(try_catch);
  }
}