XMPP: AngularJs + Strophe.js

后端 未结 3 1772
日久生厌
日久生厌 2021-02-06 16:22

I have a basic XMPP client working on strophe.js.

On login I create handlers such as

connect = new Strophe.Connection(\'http://localhost/http-bind\');
..         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-06 17:28

    As suggested above (or bellow) I wrapped strophe in a service so my login "mechanism" looks like this:

    .controller('loginCtrl', function(xmppAuth) {
    
        xmppAuth.auth(login, password);
    
    })
    

    any my service:

    .service('xmppAuth', function() {
    
    return {
    
    auth: function(login, password) {
       connect = new Strophe.Connection('http://mydomain.net/http-bind');
       connect.connect(login, password, function (status) {
           if (status === Strophe.Status.CONNECTED) {
               // we are in, addHandlers and stuff
           }
       }
    }
    
    }
    
    })
    

提交回复
热议问题