Mercurial > xmpp-account-manager
diff client.js @ 45:8b69b3a1ef8e
Add support for WebSocket.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 23 May 2020 18:58:01 +0200 |
parents | fe59565063af |
children | 010b905a74d4 |
line wrap: on
line diff
--- a/client.js +++ b/client.js @@ -74,18 +74,20 @@ document.addEventListener('DOMContentLoa const xml = evt.target.responseXML; const links = parseXPath(xml, './xrd:XRD/xrd:Link', XPathResult.ORDERED_NODE_ITERATOR_TYPE); let bosh_service = null; + let ws_service = null; while (true) { const link = links.iterateNext(); if (!link) break; - if (link.getAttributeNS(null, 'rel') == 'urn:xmpp:alt-connections:xbosh') { + const rel = link.getAttributeNS(null, 'rel'); + if (rel == 'urn:xmpp:alt-connections:xbosh') bosh_service = link.getAttributeNS(null, 'href'); - break; - } - // TODO: also support WebSocket. + else if (rel == 'urn:xmpp:alt-connections:websocket') + ws_service = link.getAttributeNS(null, 'href'); } console.log('bosh_service', bosh_service); - resolve(bosh_service); + console.log('ws_service', ws_service); + resolve(ws_service || bosh_service); }; xhr.open('GET', url); xhr.send();