Skip to content
Snippets Groups Projects
Commit 7c11d095 authored by Asad Salman's avatar Asad Salman
Browse files

added correct newCallCreated callback

Change-Id: Id05c1f9198b80bc459fa0e2250b37ecb93a52060
parent 2038837b
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,6 @@ Persistent<Function> callStateChangedCb;
Persistent<Function> incomingMessageCb;
Persistent<Function> incomingCallCb;
Persistent<Function> newCallCreatedCb;
Persistent<Function> sipCallStateChangedCb;
std::queue<std::function<void() >> pendingSignals;
std::mutex pendingSignalsLock;
......@@ -65,8 +64,6 @@ Persistent<Function>* getPresistentCb(const std::string &signal) {
return &incomingCallCb;
else if (signal == "NewCallCreated")
return &newCallCreatedCb;
else if (signal == "SipCallStateChanged")
return &sipCallStateChangedCb;
else return nullptr;
}
......@@ -332,3 +329,16 @@ void incomingCall(const std::string& account_id, const std::string& call_id, con
uv_async_send(&signalAsync);
}
void newCallCreated(const std::string& account_id, const std::string& call_id, const std::string& to_uri) {
std::lock_guard<std::mutex> lock(pendingSignalsLock);
pendingSignals.emplace([account_id, call_id, to_uri]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), newCallCreatedCb);
if (!func.IsEmpty()) {
Local<Value> callback_args[] = {V8_STRING_NEW(account_id), V8_STRING_NEW(call_id), V8_STRING_NEW(to_uri)};
func->Call(SWIGV8_CURRENT_CONTEXT()->Global(), 3, callback_args);
}
});
uv_async_send(&signalAsync);
}
\ No newline at end of file
......@@ -135,7 +135,7 @@ void init(const v8::Handle<v8::Value> &funcMap){
exportable_callback<CallSignal::StateChange>(bind(&callStateChanged, _1, _2, _3)),
exportable_callback<CallSignal::IncomingMessage>(bind(&incomingMessage, _1, _2, _3)),
exportable_callback<CallSignal::IncomingCall>(bind(&incomingCall, _1, _2, _3)),
//exportable_callback<CallSignal::NewCallCreated>(bind(&newCallCreated, _1, _2, _3))
exportable_callback<CallSignal::NewCallCreated>(bind(&newCallCreated, _1, _2, _3))
};
const std::map<std::string, SharedCallback> configEvHandlers = {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment