# HG changeset patch # User Emmanuel Gil Peyrot # Date 1590253081 -7200 # Node ID 8b69b3a1ef8eeb48550d0a6d002c5035cdbcaf25 # Parent 1b07435c7891e091dac4fde864a6566823090eb7 Add support for WebSocket. diff --git a/client.js b/client.js --- 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();