Mercurial > xmpp-account-manager
changeset 45:8b69b3a1ef8e
Add support for WebSocket.
author | Emmanuel Gil Peyrot <linkmauve@linkmauve.fr> |
---|---|
date | Sat, 23 May 2020 18:58:01 +0200 |
parents | 1b07435c7891 |
children | af2874ff7234 |
files | client.js |
diffstat | 1 files changed, 7 insertions(+), 5 deletions(-) [+] |
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();