diff options
Diffstat (limited to 'webclient/lib/basic.js')
| -rw-r--r-- | webclient/lib/basic.js | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/webclient/lib/basic.js b/webclient/lib/basic.js index 8a5d4e3..8ea5b5b 100644 --- a/webclient/lib/basic.js +++ b/webclient/lib/basic.js @@ -1,4 +1,4 @@ -var BOSH_SERVICE = 'http://alias.fr.nf/http-bind/' +var BOSH_SERVICE = 'http://alias.fr.nf/http-bind/'; var connection = null; function log(msg) @@ -18,22 +18,43 @@ function rawOutput(data) function onConnect(status) { + var jid = $('#jid').get(0).value; if (status == Strophe.Status.CONNECTING) { - log('Strophe is connecting.'); - } else if (status == Strophe.Status.CONNFAIL) { - log('Strophe failed to connect.'); - $('#connect').get(0).value = 'connect'; - } else if (status == Strophe.Status.DISCONNECTING) { - log('Strophe is disconnecting.'); - } else if (status == Strophe.Status.DISCONNECTED) { - log('Strophe is disconnected.'); - $('#connect').get(0).value = 'connect'; - } else if (status == Strophe.Status.CONNECTED) { - log('Strophe is connected.'); - connection.disconnect(); + log('Strophe is connecting.'); } + else if (status == Strophe.Status.CONNFAIL) { + log('Strophe failed to connect.'); + $('#connect').get(0).value = 'connect'; + } + else if (status == Strophe.Status.DISCONNECTING) { + log('Strophe is disconnecting.'); + } + else if (status == Strophe.Status.DISCONNECTED) { + log('Strophe is disconnected.'); + $('#connect').get(0).value = 'connect'; + } + else if (status == Strophe.Status.CONNECTED) { + log('Strophe is connected.'); + connection.addHandler(onRoster,Strophe.NS.ROSTER,'iq','result',null, null); + connection.send($pres().tree()); + var roster = $iq({type:'get'}).c('query',{xmlns: Strophe.NS.ROSTER }); + connection.send(roster.tree()); + } +} + +function onRoster(iq) +{ + var elems = iq.getElementsByTagName('query'); + var query = elems[0]; + Strophe.forEachChild(query,'item',function (item){ + var name = item.getAttribute('jid'); + $('#contacts > ul').append('<li>'+name+'</li>'); + }); + return true; } + + $(document).ready(function () { connection = new Strophe.Connection(BOSH_SERVICE); connection.rawInput = rawInput; |
