summaryrefslogtreecommitdiff
path: root/modules/presence
diff options
context:
space:
mode:
authorJuha Heinanen <jh@tutpro.com>2014-11-19 06:01:19 +0200
committerJuha Heinanen <jh@tutpro.com>2014-11-19 06:01:19 +0200
commit43a5a94f5b109cfa291f235f3fe7430d76a8a772 (patch)
treefab76c6c79d773d544e67d04798a5c4fd0ad1faa /modules/presence
parent242a6ba6b12c22747683f8548fb3e9377017c1de (diff)
presence: publish online status when ua first registers successfully
- reset publish fail count to 0 after success - shortened initial publish delay to 10 ms
Diffstat (limited to 'modules/presence')
-rw-r--r--modules/presence/publisher.c33
1 files changed, 30 insertions, 3 deletions
diff --git a/modules/presence/publisher.c b/modules/presence/publisher.c
index 883ffd7..b00096e 100644
--- a/modules/presence/publisher.c
+++ b/modules/presence/publisher.c
@@ -189,10 +189,11 @@ static void tmr_handler(void *arg)
{
struct publisher *pub = arg;
- if (publish(pub)) {
+ if (publish(pub))
tmr_start(&pub->tmr, wait_fail(++pub->failc) * 1000,
tmr_handler, pub);
- }
+ else
+ pub->failc = 0;
}
@@ -235,7 +236,7 @@ static int publisher_alloc(struct ua *ua)
pub->expires = account_pubint(ua_account(ua));
tmr_init(&pub->tmr);
- tmr_start(&pub->tmr, 100, tmr_handler, pub);
+ tmr_start(&pub->tmr, 10, tmr_handler, pub);
list_append(&publ, &pub->le, pub);
@@ -243,11 +244,35 @@ static int publisher_alloc(struct ua *ua)
}
+static void pub_ua_event_handler(struct ua *ua,
+ enum ua_event ev,
+ struct call *call,
+ const char *prm,
+ void *arg )
+{
+ (void)call;
+ (void)prm;
+ (void)arg;
+
+ if (account_pubint(ua_account(ua)) == 0)
+ return;
+
+ if (ev == UA_EVENT_REGISTER_OK) {
+ if (ua_presence_status(ua) == PRESENCE_UNKNOWN) {
+ ua_presence_status_set(ua, PRESENCE_OPEN);
+ publisher_update_status(ua);
+ }
+ }
+}
+
+
int publisher_init(void)
{
struct le *le;
int err = 0;
+ uag_event_register(pub_ua_event_handler, NULL);
+
for (le = list_head(uag_list()); le; le = le->next) {
struct ua *ua = le->data;
@@ -270,6 +295,8 @@ void publisher_close(void)
{
struct le *le;
+ uag_event_unregister(pub_ua_event_handler);
+
for (le = list_head(&publ); le; le = le->next) {
struct publisher *pub = le->data;