Skip to content

Commit

Permalink
presence_reginfo: Add option for aggregating presentities
Browse files Browse the repository at this point in the history
  • Loading branch information
Matteo Brancaleoni authored and henningw committed Sep 27, 2022
1 parent 1fbdc35 commit 91cf0ce
Show file tree
Hide file tree
Showing 6 changed files with 420 additions and 2 deletions.
19 changes: 19 additions & 0 deletions src/modules/presence_reginfo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,25 @@ include ../../Makefile.defs
auto_gen=
NAME=presence_reginfo.so

ifeq ($(CROSS_COMPILE),)
XML2CFG=$(shell which xml2-config)
ifeq ($(XML2CFG),)
XML2CFG=$(shell \
if pkg-config --exists libxml-2.0; then \
echo 'pkg-config libxml-2.0'; \
fi)
endif
endif

ifneq ($(XML2CFG),)
DEFS += $(shell $(XML2CFG) --cflags )
LIBS += $(shell $(XML2CFG) --libs)
else
DEFS+=-I$(LOCALBASE)/include/libxml2 \
-I$(LOCALBASE)/include
LIBS+=-L$(LOCALBASE)/lib -lxml2
endif

include ../../Makefile.modules


Expand Down
17 changes: 15 additions & 2 deletions src/modules/presence_reginfo/add_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "../../core/parser/parse_content.h"
#include "../presence/event_list.h"
#include "presence_reginfo.h"
#include "notify_body.h"

extern int pres_reginfo_aggregate_presentities;

int reginfo_add_events(void)
{
Expand All @@ -39,12 +42,22 @@ int reginfo_add_events(void)

event.content_type.s = "application/reginfo+xml";
event.content_type.len = 23;
event.default_expires= pres_reginfo_default_expires;
event.default_expires = pres_reginfo_default_expires;
event.type = PUBL_TYPE;
event.req_auth = 0;
event.evs_publ_handl = 0;

if (pres_add_event(&event) < 0) {

if(pres_reginfo_aggregate_presentities) {
/* aggregate XML body and free() fuction */
event.agg_nbody = reginfo_agg_nbody;
event.free_body = free_xml_body;
/* modify XML body for each watcher to set the correct "version" */
event.aux_body_processing = reginfo_body_setversion;
event.aux_free_body = free_xml_body;
}

if(pres_add_event(&event) < 0) {
LM_ERR("failed to add event \"reginfo\"\n");
return -1;
}
Expand Down
21 changes: 21 additions & 0 deletions src/modules/presence_reginfo/doc/presence_reginfo_admin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,27 @@
</example>
</section>

<section id="presence_reginfo.p.aggregate_presentities">
<title><varname>aggregate_presentities</varname> (int)</title>
<para>
Whether to aggregate in a single notify body all registration
presentities. Useful to have all registrations on first NOTIFY
following initial SUBSCRIBE.
</para>
<para>
<emphasis>Default value is <quote>0</quote> (disabled).
</emphasis>
</para>
<example>
<title>Set <varname>aggregate_presentities</varname> parameter</title>
<programlisting format="linespecific">
...
modparam("presence_reginfo", "aggregate_presentities", 1)
...
</programlisting>
</example>
</section>

</section>


Expand Down
Loading

0 comments on commit 91cf0ce

Please sign in to comment.