Annotate

mod_tcpproxy/web/xmpp.io.js @ 6302:06fbbd45ba75

mod_cloud_notify: Readme: fix links and labels that were removed in the last commit diff --git a/mod_cloud_notify/README.md b/mod_cloud_notify/README.md --- a/mod_cloud_notify/README.md +++ b/mod_cloud_notify/README.md @@ -1,3 +1,9 @@ +---- +-labels: +-- 'Stage-Beta' +-summary: 'XEP-0357: Cloud push notifications' +---- + # Introduction This module enables support for sending "push notifications" to clients @@ -32,15 +38,15 @@ notification to your device. When your d it will display it or wake up the app so it can connect to XMPP and receive any pending messages. -This protocol is described for developers in \[XEP-0357: Push -Notifications\]. +This protocol is described for developers in [XEP-0357: Push +Notifications]. -For this module to work reliably, you must have \[mod_smacks\], -\[mod_mam\] and \[mod_carbons\] also enabled on your server. +For this module to work reliably, you must have [mod_smacks], +[mod_mam] and [mod_carbons] also enabled on your server. Some clients, notably Siskin and Snikket iOS need some additional extensions that are not currently defined in a standard XEP. To support -these clients, see \[mod_cloud_notify_extensions\]. +these clients, see [mod_cloud_notify_extensions]. # Configuration @@ -58,18 +64,18 @@ these clients, see \[mod_cloud_notify_ex # Internal design notes App servers are notified about offline messages, messages stored by -\[mod_mam\] or messages waiting in the smacks queue. The business rules +[mod_mam] or messages waiting in the smacks queue. The business rules outlined [here](//mail.jabber.org/pipermail/standards/2016-February/030925.html) are all honored[^2]. -To cooperate with \[mod_smacks\] this module consumes some events: +To cooperate with [mod_smacks] this module consumes some events: `smacks-ack-delayed`, `smacks-hibernation-start` and `smacks-hibernation-end`. These events allow this module to send out notifications for messages received while the session is hibernated by -\[mod_smacks\] or even when smacks acknowledgements for messages are +[mod_smacks] or even when smacks acknowledgements for messages are delayed by a certain amount of seconds configurable with the -\[mod_smacks\] setting `smacks_max_ack_delay`. +[mod_smacks] setting `smacks_max_ack_delay`. The `smacks_max_ack_delay` setting allows to send out notifications to clients which aren't already in smacks hibernation state (because the
author Menel <menel@snikket.de>
date Fri, 13 Jun 2025 10:44:37 +0200
parent 1343:7dbde05b48a9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
148
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 var xmlns_ibb = "http://jabber.org/protocol/ibb";
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2 var xmlns_tcp = "http://prosody.im/protocol/tcpproxy";
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4 function XMPPIO(xmppconn, xmpptcp_host)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 this.xmppconn = xmppconn;
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7 this.xmpphost = xmpptcp_host;
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 this.sid = "FIXME";
1343
7dbde05b48a9 all the things: Remove trailing whitespace
Florian Zeitz <florob@babelmonkeys.de>
parents: 148
diff changeset
9
148
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 this.listeners = [];
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 return this;
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 }
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14 XMPPIO.prototype = {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 connect: function (host, port)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 var conn = this;
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18 console.log("Connecting...");
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
19
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
20 function onConnect()
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
21 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
22 this.xmppconn.addHandler(function (stanza)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
23 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
24 var data = stanza.getElementsByTagName("data")[0];
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
25 if(data)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
26 conn.emit("data", Strophe.Base64.decode(Strophe.getText(data)));
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 }, null, "message", null, null, this.xmpphost, {});
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
28 this.xmppconn.addHandler(function (stanza)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
29 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
30 var data = stanza.getElementsByTagName("close")[0];
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
31 if(close)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
32 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
33 conn.write = function () { throw "Connection closed"; };
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
34 conn.emit("end");
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
35 }
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
36 }, xmlns_ibb, "iq", "set", null, this.xmpphost, {});
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
37 conn.emit("connect");
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
38 }
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
39
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
40 this.xmppconn.sendIQ($iq({to:this.xmpphost,type:"set"})
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
41 .c("open", {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
42 "xmlns": xmlns_ibb,
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
43 "xmlns:tcp": xmlns_tcp,
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
44 "tcp:host": host,
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
45 "tcp:port": port.toString(),
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
46 "block-size": "4096",
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
47 "sid": this.sid.toString(),
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
48 "stanza": "message"
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
49 }), onConnect,
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
50 function () { conn.emit("error"); });
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
51 },
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
52 emit: function ()
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
53 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
54 console.log("xmpp.io: Emitting "+arguments[0]);
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
55 var args = Array.prototype.slice.call(arguments, 1);
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
56 var listeners = this.listeners[arguments[0]];
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
57 if(listeners)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
58 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
59 for(var i=0;i<listeners.length;i++)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
60 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
61 listeners[i][1].apply(listeners[i][0], args);
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
62 }
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
63 }
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
64 },
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
65 addListener: function (event, method, obj)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
66 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
67 if(typeof(obj)=="undefined")
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
68 obj = this;
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
69 if(!(event in this.listeners))
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
70 this.listeners[event] = [];
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
71 this.listeners[event].push([obj, method]);
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
72 },
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
73 write: function (data)
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
74 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
75 return this.xmppconn.send($msg({to:this.xmpphost})
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
76 .c("data", {xmlns:xmlns_ibb, sid:this.sid.toString()})
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
77 .t(Strophe.Base64.encode(data)));
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
78 },
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
79 end: function ()
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
80 {
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
81 return this.xmppconn.send($iq({to:this.xmpphost})
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
82 .c("close", {xmlns:xmlns_ibb, sid:this.sid.toString()}));
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
83 }
f2f9b965d1ad mod_tcpproxy: Add web/ folder containing demo JS client
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
84 };