Mercurial > xmpp-account-manager
annotate util.js @ 1:d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Fri, 21 Dec 2018 23:44:18 +0100 |
parents | |
children | 5aa1bf7154b0 |
rev | line source |
---|---|
1
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
1 function nsResolver(prefix) { |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
2 return { |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
3 xrd: 'http://docs.oasis-open.org/ns/xri/xrd-1.0', |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
4 pubsub: 'http://jabber.org/protocol/pubsub', |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
5 avatar_metadata: 'urn:xmpp:avatar:metadata', |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
6 avatar_data: 'urn:xmpp:avatar:data', |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
7 nickname: 'http://jabber.org/protocol/nick', |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
8 }[prefix] || null; |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
9 } |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
10 |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
11 function parseXPath(elem, xpath, result) |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
12 { |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
13 if (result === undefined) |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
14 result = XPathResult.FIRST_ORDERED_NODE_TYPE; |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
15 const value = elem.getRootNode().evaluate(xpath, elem, nsResolver, result, null); |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
16 if (result == XPathResult.FIRST_ORDERED_NODE_TYPE) |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
17 return value.singleNodeValue; |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
18 return value; |
d6df73b466f6
Implement XEP-0156 to discover the right BOSH endpoint.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff
changeset
|
19 } |