Browse code

presence: new rpc command presence.updateWatchers

- trigger update of watchers via rpc

Daniel-Constantin Mierla authored on 23/06/2019 09:35:36
Showing 1 changed files
... ...
@@ -1728,6 +1728,49 @@ void rpc_presence_refresh_watchers(rpc_t *rpc, void *ctx)
1728 1728
 static const char *rpc_presence_refresh_watchers_doc[2] = {
1729 1729
 		"Trigger refresh of watchers", 0};
1730 1730
 
1731
+/*! \brief
1732
+ *  rpc cmd: presence.updateWatchers
1733
+ *			\<presentity_uri>
1734
+ *			\<event>
1735
+ *		* */
1736
+void rpc_presence_update_watchers(rpc_t *rpc, void *ctx)
1737
+{
1738
+	str pres_uri = {0, 0};
1739
+	str event = {0, 0};
1740
+	int pn;
1741
+
1742
+	LM_DBG("init update of watchers\n");
1743
+
1744
+	pn = rpc->scan(ctx, "SS", &pres_uri, &event);
1745
+	if(pn < 2) {
1746
+		rpc->fault(ctx, 500, "Not enough parameters");
1747
+		return;
1748
+	}
1749
+
1750
+	if(pres_uri.s == NULL || pres_uri.len == 0) {
1751
+		LM_ERR("empty uri\n");
1752
+		rpc->fault(ctx, 500, "Empty presentity URI");
1753
+		return;
1754
+	}
1755
+
1756
+	if(event.s == NULL || event.len == 0) {
1757
+		LM_ERR("empty event parameter\n");
1758
+		rpc->fault(ctx, 500, "Empty event parameter");
1759
+		return;
1760
+	}
1761
+	LM_DBG("uri '%.*s' - event '%.*s'\n", pres_uri.len, pres_uri.s,
1762
+			event.len, event.s);
1763
+
1764
+	if(ki_pres_update_watchers(NULL, &pres_uri, &event)<0) {
1765
+		rpc->fault(ctx, 500, "Processing error");
1766
+		return;
1767
+	}
1768
+}
1769
+
1770
+static const char *rpc_presence_update_watchers_doc[2] = {
1771
+		"Trigger update of watchers", 0};
1772
+
1773
+
1731 1774
 void rpc_presence_cleanup(rpc_t *rpc, void *c)
1732 1775
 {
1733 1776
 	LM_DBG("rpc_presence_cleanup:start\n");
... ...
@@ -1749,6 +1792,8 @@ rpc_export_t presence_rpc[] = {
1749 1792
 		{"presence.cleanup", rpc_presence_cleanup, rpc_presence_cleanup_doc, 0},
1750 1793
 		{"presence.refreshWatchers", rpc_presence_refresh_watchers,
1751 1794
 				rpc_presence_refresh_watchers_doc, 0},
1795
+		{"presence.updateWatchers", rpc_presence_update_watchers,
1796
+				rpc_presence_update_watchers_doc, 0},
1752 1797
 		{0, 0, 0, 0}};
1753 1798
 
1754 1799
 static int presence_init_rpc(void)