Skip to content
Snippets Groups Projects
Commit 4268eb2b authored by Adrien Béraud's avatar Adrien Béraud
Browse files

nodejs: add missing method

Change-Id: Id5fd5d03bbc809ce0dfd9e318e4e2534838c1651
parent b3877e77
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,7 @@
using namespace v8;
Persistent<Function> accountsChangedCb;
Persistent<Function> accountDetailsChangedCb;
Persistent<Function> registrationStateChangedCb;
Persistent<Function> volatileDetailsChangedCb;
Persistent<Function> incomingAccountMessageCb;
......@@ -34,6 +35,8 @@ uv_async_t signalAsync;
Persistent<Function>* getPresistentCb(const std::string &signal) {
if (signal == "AccountsChanged")
return &accountsChangedCb;
else if (signal == "AccountDetailsChanged")
return &accountDetailsChangedCb;
else if (signal == "RegistrationStateChanged")
return &registrationStateChangedCb;
else if (signal == "VolatileDetailsChanged")
......@@ -142,6 +145,22 @@ void volatileDetailsChanged(const std::string& account_id, const std::map<std::s
uv_async_send(&signalAsync);
}
void accountDetailsChanged(const std::string& accountId, const std::map<std::string, std::string>& details) {
std::lock_guard<std::mutex> lock(pendingSignalsLock);
pendingSignals.emplace([accountId, details]() {
Local<Function> func = Local<Function>::New(Isolate::GetCurrent(), accountDetailsChangedCb);
if (!func.IsEmpty()) {
Local<Object> jsDetails = SWIGV8_OBJECT_NEW();
stringMapToJsMap(payloads, jsDetails);
Local<Value> callback_args[] = {V8_STRING_NEW_LOCAL(accountId), jsDetails};
func->Call(SWIGV8_CURRENT_CONTEXT(), SWIGV8_NULL(), 2, callback_args);
}
});
uv_async_send(&signalAsync);
}
void accountsChanged() {
std::lock_guard<std::mutex> lock(pendingSignalsLock);
......
......@@ -125,6 +125,7 @@ void init(const SWIGV8_VALUE& funcMap){
const std::map<std::string, SharedCallback> configEvHandlers = {
exportable_callback<ConfigurationSignal::AccountsChanged>(bind(&accountsChanged)),
exportable_callback<ConfigurationSignal::AccountDetailsChanged>(bind(&accountDetailsChanged, _1, _2)),
exportable_callback<ConfigurationSignal::RegistrationStateChanged>(bind(&registrationStateChanged, _1, _2, _3, _4)),
exportable_callback<ConfigurationSignal::ContactAdded>(bind(&contactAdded, _1, _2, _3 )),
exportable_callback<ConfigurationSignal::ContactRemoved>(bind(&contactRemoved, _1, _2, _3 )),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment