-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattention.js
39 lines (36 loc) · 1.03 KB
/
attention.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/**
* @file attention.js
* Implements XEP-0224 (Attention).
* @author Christoph Burschka
* @see http://xmpp.org/extensions/xep-0224.html
*/
define(['strophe.js'], ({Strophe}) => {
Strophe.addNamespace('ATTENTION', 'urn:xmpp:attention:0');
Strophe.addConnectionPlugin('attention', {
init(conn) {
this._c = conn;
},
/**
* Add <attention> to a message stanza.
* The stanza must be generated and sent by the caller.
*
* @param {Builder} msg The message stanza builder.
* The pointer must be at the root element.
*
* @return the stanza with <attention> appended.
*/
attention(msg) {
return msg.c('attention', {xmlns: Strophe.NS.ATTENTION}, '');
},
/**
* Add a handler that listens for attention stanzas.
*
* @param {function} handler
*
* @return The reference that can be used to remove the handler.
*/
addHandler(handler) {
return this._c.addHandler(handler, Strophe.NS.ATTENTION, 'message');
}
});
});