Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
jami-daemon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
savoirfairelinux
jami-daemon
Commits
912aa59a
Commit
912aa59a
authored
5 months ago
by
Léopold Chappuis
Committed by
Adrien Béraud
5 months ago
Browse files
Options
Downloads
Patches
Plain Diff
nodejs-interface: add presence signals
Change-Id: Ifb3d176bc37c4ecbc6ce9ff682e7721d55ea7e0f
parent
35ccafac
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bin/nodejs/callback.h
+90
-0
90 additions, 0 deletions
bin/nodejs/callback.h
bin/nodejs/nodejs_interface.i
+12
-0
12 additions, 0 deletions
bin/nodejs/nodejs_interface.i
with
102 additions
and
0 deletions
bin/nodejs/callback.h
+
90
−
0
View file @
912aa59a
...
@@ -56,6 +56,11 @@ Persistent<Function> accountProfileReceivedCb;
...
@@ -56,6 +56,11 @@ Persistent<Function> accountProfileReceivedCb;
Persistent
<
Function
>
profileReceivedCb
;
Persistent
<
Function
>
profileReceivedCb
;
Persistent
<
Function
>
userSearchEndedCb
;
Persistent
<
Function
>
userSearchEndedCb
;
Persistent
<
Function
>
deviceRevocationEndedCb
;
Persistent
<
Function
>
deviceRevocationEndedCb
;
Persistent
<
Function
>
subscriptionStateChangedCb
;
Persistent
<
Function
>
nearbyPeerNotificationCb
;
Persistent
<
Function
>
newBuddyNotificationCb
;
Persistent
<
Function
>
serverErrorCb
;
Persistent
<
Function
>
newServerSubscriptionRequestCb
;
std
::
queue
<
std
::
function
<
void
()
>>
pendingSignals
;
std
::
queue
<
std
::
function
<
void
()
>>
pendingSignals
;
std
::
mutex
pendingSignalsLock
;
std
::
mutex
pendingSignalsLock
;
...
@@ -159,6 +164,16 @@ getPresistentCb(std::string_view signal)
...
@@ -159,6 +164,16 @@ getPresistentCb(std::string_view signal)
return
&
userSearchEndedCb
;
return
&
userSearchEndedCb
;
else
if
(
signal
==
"DeviceRevocationEnded"
)
else
if
(
signal
==
"DeviceRevocationEnded"
)
return
&
deviceRevocationEndedCb
;
return
&
deviceRevocationEndedCb
;
else
if
(
signal
==
"SubscriptionStateChanged"
)
return
&
subscriptionStateChangedCb
;
else
if
(
signal
==
"NearbyPeerNotification"
)
return
&
nearbyPeerNotificationCb
;
else
if
(
signal
==
"NewBuddyNotification"
)
return
&
newBuddyNotificationCb
;
else
if
(
signal
==
"ServerError"
)
return
&
serverErrorCb
;
else
if
(
signal
==
"NewServerSubscriptionRequest"
)
return
&
newServerSubscriptionRequestCb
;
else
else
return
nullptr
;
return
nullptr
;
}
}
...
@@ -1163,3 +1178,78 @@ profileReceived(const std::string& accountId,
...
@@ -1163,3 +1178,78 @@ profileReceived(const std::string& accountId,
uv_async_send
(
&
signalAsync
);
uv_async_send
(
&
signalAsync
);
}
}
void
subscriptionStateChanged
(
const
std
::
string
&
accountId
,
const
std
::
string
&
buddy_uri
,
int
state
)
{
std
::
lock_guard
lock
(
pendingSignalsLock
);
pendingSignals
.
emplace
([
accountId
,
buddy_uri
,
state
]()
{
Local
<
Function
>
func
=
Local
<
Function
>::
New
(
Isolate
::
GetCurrent
(),
subscriptionStateChangedCb
);
if
(
!
func
.
IsEmpty
())
{
SWIGV8_VALUE
callback_args
[]
=
{
V8_STRING_NEW_LOCAL
(
accountId
),
V8_STRING_NEW_LOCAL
(
buddy_uri
),
SWIGV8_INTEGER_NEW
(
state
)};
func
->
Call
(
SWIGV8_CURRENT_CONTEXT
(),
SWIGV8_NULL
(),
3
,
callback_args
);
}
});
uv_async_send
(
&
signalAsync
);
}
void
nearbyPeerNotification
(
const
std
::
string
&
accountId
,
const
std
::
string
&
buddy_uri
,
int
state
,
const
std
::
string
&
displayName
){
std
::
lock_guard
lock
(
pendingSignalsLock
);
pendingSignals
.
emplace
([
accountId
,
buddy_uri
,
state
,
displayName
]()
{
Local
<
Function
>
func
=
Local
<
Function
>::
New
(
Isolate
::
GetCurrent
(),
nearbyPeerNotificationCb
);
if
(
!
func
.
IsEmpty
())
{
SWIGV8_VALUE
callback_args
[]
=
{
V8_STRING_NEW_LOCAL
(
accountId
),
V8_STRING_NEW_LOCAL
(
buddy_uri
),
SWIGV8_INTEGER_NEW
(
state
),
V8_STRING_NEW_LOCAL
(
displayName
)};
func
->
Call
(
SWIGV8_CURRENT_CONTEXT
(),
SWIGV8_NULL
(),
4
,
callback_args
);
}
});
uv_async_send
(
&
signalAsync
);
}
void
newBuddyNotification
(
const
std
::
string
&
accountId
,
const
std
::
string
&
buddy_uri
,
int
status
,
const
std
::
string
&
line_status
){
std
::
lock_guard
lock
(
pendingSignalsLock
);
pendingSignals
.
emplace
([
accountId
,
buddy_uri
,
status
,
line_status
]()
{
Local
<
Function
>
func
=
Local
<
Function
>::
New
(
Isolate
::
GetCurrent
(),
newBuddyNotificationCb
);
if
(
!
func
.
IsEmpty
())
{
SWIGV8_VALUE
callback_args
[]
=
{
V8_STRING_NEW_LOCAL
(
accountId
),
V8_STRING_NEW_LOCAL
(
buddy_uri
),
SWIGV8_INTEGER_NEW
(
status
),
V8_STRING_NEW_LOCAL
(
line_status
)};
func
->
Call
(
SWIGV8_CURRENT_CONTEXT
(),
SWIGV8_NULL
(),
4
,
callback_args
);
}
});
uv_async_send
(
&
signalAsync
);
}
void
newServerSubscriptionRequest
(
const
std
::
string
&
remote
){
std
::
lock_guard
lock
(
pendingSignalsLock
);
pendingSignals
.
emplace
([
remote
]()
{
Local
<
Function
>
func
=
Local
<
Function
>::
New
(
Isolate
::
GetCurrent
(),
newServerSubscriptionRequestCb
);
if
(
!
func
.
IsEmpty
())
{
SWIGV8_VALUE
callback_args
[]
=
{
V8_STRING_NEW_LOCAL
(
remote
)};
func
->
Call
(
SWIGV8_CURRENT_CONTEXT
(),
SWIGV8_NULL
(),
1
,
callback_args
);
}
});
uv_async_send
(
&
signalAsync
);
}
void
serverError
(
const
std
::
string
&
accountId
,
const
std
::
string
&
error
,
const
std
::
string
&
msg
){
std
::
lock_guard
lock
(
pendingSignalsLock
);
pendingSignals
.
emplace
([
accountId
,
error
,
msg
]()
{
Local
<
Function
>
func
=
Local
<
Function
>::
New
(
Isolate
::
GetCurrent
(),
serverErrorCb
);
if
(
!
func
.
IsEmpty
())
{
SWIGV8_VALUE
callback_args
[]
=
{
V8_STRING_NEW_LOCAL
(
accountId
),
V8_STRING_NEW_LOCAL
(
error
),
V8_STRING_NEW_LOCAL
(
msg
)};
func
->
Call
(
SWIGV8_CURRENT_CONTEXT
(),
SWIGV8_NULL
(),
3
,
callback_args
);
}
});
uv_async_send
(
&
signalAsync
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
bin/nodejs/nodejs_interface.i
+
12
−
0
View file @
912aa59a
...
@@ -115,6 +115,7 @@ void init(const SWIGV8_VALUE& funcMap){
...
@@ -115,6 +115,7 @@ void init(const SWIGV8_VALUE& funcMap){
using libjami::ConfigurationSignal;
using libjami::ConfigurationSignal;
using libjami::CallSignal;
using libjami::CallSignal;
using libjami::ConversationSignal;
using libjami::ConversationSignal;
using libjami::PresenceSignal;
using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>;
using SharedCallback = std::shared_ptr<libjami::CallbackWrapperBase>;
const std::map<std::string, SharedCallback> callEvHandlers = {
const std::map<std::string, SharedCallback> callEvHandlers = {
exportable_callback<CallSignal::StateChange>(bind(&callStateChanged, _1, _2, _3, _4)),
exportable_callback<CallSignal::StateChange>(bind(&callStateChanged, _1, _2, _3, _4)),
...
@@ -171,6 +172,16 @@ void init(const SWIGV8_VALUE& funcMap){
...
@@ -171,6 +172,16 @@ void init(const SWIGV8_VALUE& funcMap){
exportable_callback<ConversationSignal::ConversationPreferencesUpdated>(bind(&conversationPreferencesUpdated, _1, _2, _3))
exportable_callback<ConversationSignal::ConversationPreferencesUpdated>(bind(&conversationPreferencesUpdated, _1, _2, _3))
};
};
// Presence event handlers
const std::map<std::string, SharedCallback> presenceEvHandlers = {
exportable_callback<PresenceSignal::NewServerSubscriptionRequest>(bind(&newServerSubscriptionRequest, _1 )),
exportable_callback<PresenceSignal::ServerError>(bind(&serverError, _1, _2, _3 )),
exportable_callback<PresenceSignal::NewBuddyNotification>(bind(&newBuddyNotification, _1, _2, _3, _4 )),
exportable_callback<PresenceSignal::NearbyPeerNotification>(bind(&nearbyPeerNotification, _1, _2, _3, _4)),
exportable_callback<PresenceSignal::SubscriptionStateChanged>(bind(&subscriptionStateChanged, _1, _2, _3 ))
};
if (!libjami::init(static_cast<libjami::InitFlag>(libjami::LIBJAMI_FLAG_DEBUG)))
if (!libjami::init(static_cast<libjami::InitFlag>(libjami::LIBJAMI_FLAG_DEBUG)))
return;
return;
...
@@ -178,6 +189,7 @@ void init(const SWIGV8_VALUE& funcMap){
...
@@ -178,6 +189,7 @@ void init(const SWIGV8_VALUE& funcMap){
registerSignalHandlers(callEvHandlers);
registerSignalHandlers(callEvHandlers);
registerSignalHandlers(conversationHandlers);
registerSignalHandlers(conversationHandlers);
registerSignalHandlers(dataTransferEvHandlers);
registerSignalHandlers(dataTransferEvHandlers);
registerSignalHandlers(presenceEvHandlers);
libjami::start();
libjami::start();
}
}
%}
%}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment