librelist archives

« back to archive

prebind implementation w/ 0.8.3

prebind implementation w/ 0.8.3

From:
Anton Popov
Date:
2014-09-23 @ 12:46
could not decode message

Re: [conversejs] prebind implementation w/ 0.8.3

From:
Juan Chavat
Date:
2014-09-23 @ 15:12
Hi Anton,
You can try enabling the expose_rid_and_sid flag in the initialization but
take care because you can have some security issues bc of that.
Cheers,
Jp

2014-09-23 9:46 GMT-03:00 Anton Popov <anton.popov@iconmobile.com>:

> Hi,
>
> I used to have the code below but now the behavior has changed.
>
> It stayed logged on after a reload, but users were shown offline (bug
> #175))
>
> I used localStorage to save the sid, jid and rid but now I only get the
> jid. Rid and Sid do not get set.
>
> I can’t find the sid or rid in sessionStorage as well..
>
> Is there a working/official/good way of doing this?
>
>
>
> Thanks,
>
> Anton
>
>
>
>
>
>
>
> <html>
>
>     <head>
>
>         <meta charset='utf-8' />
>
>          <meta http-equiv="Content-Type" content="text/html;
> charset=utf-8" />
>
>         <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
>
>         <meta name="description" content="iconmobile web chat" />
>
>           <link rel="stylesheet" type="text/css" media="screen"
> href="stylesheets/stylesheet.css">
>
> &n bsp;       <link rel="stylesheet" type="text/css" media="screen" href="
> https://domain.com/converse/converse.min.css">
>
>         <script src="https://domain.com/converse/converse.min.js
> "></script>
>
>         <title>Converse.js</title>
>
>     </head>
>
>     <body>
>
>         <div id="conversejs"></div>
>
>     </body>
>
>     <script>
>
>         require(['converse'], function(converse) {
>
>             var info;
>
> if (localStorage && localStorage.converse) {
>
> info = JSON.parse(localStorage.converse).info;
>
> }
>
>            if (localStorage && localStorage.converse && info.jid ) {
>
>                 converse.initialize({
>
>                     prebind: true,
>
>                     jid: info.jid,
>
>                     sid: info.sid,
>
>                     rid: info.rid,
>
>                     allow_otr: false,
>
>    &nb sp;                auto_list_rooms: false,
>
>                     allow_muc: false,
>
>                     auto_subscribe: true,
>
>                     auto_reconnect: true,
>
>       &nbs p;             bosh_service_url: 'https://domain.com/http-bind
> ',
>
>                     debug: true,
>
>                     hide_muc_server: true,
>
>                     i18n: locales['en'],
>
>       &n bsp;             use_otr_by_default: true,
>
>                     show_only_online_users: true,
>
>                     xhr_user_search: false
>
>                 });
>
>             } else {
>
>                 converse.initialize({
>
>                     allow_otr: false,
>
>                     auto_list_rooms: false,
>
>                     auto_subscribe: true,
>
>                     bosh_service_url: 'https://domain.com/http-bind',
>
>                     debug: true,
>
>                     hide_muc_server: true,
>
>                     allow_muc: false,
>
>                     i18n: locales['en'],
>
>                     use_otr_by_default: true,
>
>                     show_only_online_users: true,
>
>                     xhr_user_search: false
>
>                 }, function() {
>
>                     var that = this;
>
>                     $(window).unload(function(event) {
>
>                         if (typeof that.connection !== "undefined") {
>
>                             localStorage.setItem('converse',
> JSON.stringify({info: {
>
>
> jid: that.connection.jid,
>
>
> rid: that.connection.rid,
>
>
>                  sid: that.connection.sid}
>
> }));}});});}});
>
> </script>
>
> </html>
>

Re: [conversejs] prebind implementation w/ 0.8.3

From:
Anton Popov
Date:
2014-09-24 @ 07:03
could not decode message

Re: [conversejs] prebind implementation w/ 0.8.3

From:
Jc Brand
Date:
2014-09-24 @ 09:08
On Wed, Sep 24, 2014 at 07:03:03AM +0000, Anton Popov wrote:
>    Hi,
> 
>    It did not change anything.. still same behavior.
> 
>    In the debug windows I see (as before)
> 
>    <body rid=”xxx” xmlns=”xxxx” sid=”xxxx”></body>
> 
>    But how do I use them?

When you set expose_sid_and_rid to true, you get the RID and SID via
converse.getRID and converse.getSID.

Alternatively, you can also try using the "keepalive" function. Converse.js
will then automatically keep track of the SID and RID values for you.

However, be aware that all the edge-cases that might appear
when using keepalive in combination with prebind might not have
been resolved.
  
>    From: conversejs@librelist.com [mailto:conversejs@librelist.com] On Behalf
>    Of Juan Chavat
>    Sent: Tuesday, September 23, 2014 17:12
>    To: conversejs@librelist.com
>    Subject: Re: [conversejs] prebind implementation w/ 0.8.3
> 
>    Hi Anton,
> 
>    You can try enabling the expose _rid_and_sid flag in the initialization
>    but take care because you can have some security issues bc of that.
> 
>    Cheers,
>    Jp
> 
> 
>    2014-09-23 9:46 GMT-03:00 Anton Popov <[1]anton.popov@iconmobile.com>:
> 
>      Hi,
> 
>      I used to have the code below but now the behavior has changed.
> 
>      It stayed logged on af ter a reload, but users were shown offline (bug
>      #175))
> 
>      I used localStorage to save the sid, jid and rid but now I only get the
>      jid. Rid and Sid do not get set.
> 
>      I can’t find the sid or rid in sessionStorage as well..
> 
>      Is there a working/official/good way of doing this?
> 
>       
> 
>      Thanks,
> 
>      Anton
> 
>       
> 
>       
> 
>       
> 
>      <html>
> 
>          <head>
> 
>              <meta charset='utf-8' />
> 
>               <meta http-equiv="Content-Type" content="text/html;
>      charset=utf-8" />
> 
>              <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
> 
>              <meta name="description" content="iconmobile web chat" />
> 
>                <link rel="stylesheet" type="text/css" media="screen"
>      href="stylesheets/stylesheet.css">
> 
>      &n bsp;       <link rel="stylesheet" type="text/css" media="screen"
>      href="[2]https://domain.com/converse/converse.min.css">
> 
>              <script src="[3]https://domain.com/c
>      onverse/converse.min.js"></script>
> 
>              <title>Converse.js</title>
> 
>          </head>
> 
>          <body>
> 
>              <div id="conversejs"></div>
> 
>          </body>
> 
>          <script>
> 
>              require(['converse'], function(converse) {
> 
>                  var info;
> 
>      if (localStorage && localStorage.co nverse) {
> 
>      info = JSON.parse(localStorage.converse).info;
> 
>      }
> 
>                 if (localStorage && localStorage.converse && info.jid ) {
> 
>                      converse.initialize({
> 
>                          prebind: true,
> 
>                          jid: info.jid,
> 
>                          sid: info.sid,
> 
>                          rid: info.rid,
> 
>                          allow_otr: false,
> 
>         &nb sp;                auto_list_rooms: false,
> 
>                          allow_muc: false,
> 
>                          auto_subscribe: true,
> 
>                          auto_reconnect: true,
> 
>            &nbs p;             bosh_service_url:
>      '[4]https://domain.com/http-bind',
> 
>                          debug: true,
> 
>                          hide_muc_server: true,
> 
>                          i18n: locales['en'],
> 
>            &n bsp; &nbs p;           use_otr_by_default: true,
> 
>                          show_only_online_users: true,
> 
>                          xhr_user_search: false
> 
>                      });
> 
>                  } else {
> 
>                      converse.initialize({
> 
>                          allow_otr: false,
> 
>                  & nbsp;       auto_list_rooms: false,
> 
>                          auto_subscribe: true,
> 
>                          bosh_service_url: '[5]https://domain.com/http-bind',
> 
>                 &nb sp;        debug: true,
> 
>                          hide_muc_server: true,
> 
>                          allow_muc: false,
> 
>                          i18n: locales['en'],
> 
>                          use_otr_by_default: true,
> 
>                          show_only_online_users: true,
> 
>         �  �                xhr_user_search: false
> 
>                      }, function() {
> 
>                          var that = this;
> 
>                          $(window).unload(function(event) {
> 
>                              if (typeof that.connection !== "undefined") {
> 
>                                  localStorage.setItem('converse',
>      JSON.stringify({info: {
> 
>                               &nbs
>      p;                                                      jid:
>      that.connection.jid,
> 
>      
>      rid: that.connection.rid,
> 
>                                                                     
>                       sid: that.connection.sid}
> 
>      }));}});});}});
> 
>      </script>
> 
>      </html>
> 
>     
> 
> References
> 
>    Visible links
>    1. mailto:anton.popov@iconmobile.com
>    2. https://domain.com/converse/converse.min.css
>    3. https://domain.com/converse/converse.min.js
>    4. https://domain.com/http-bind
>    5. https://domain.com/http-bind

Re: [conversejs] prebind implementation w/ 0.8.3

From:
Anton Popov
Date:
2014-09-24 @ 09:51
Thanks, that worked but now after a reload I get all the users displayed, 
even the offline ones although I have show_only_online_users: true,




This is the complete code for reference:

    <script>
        require(['converse'], function(converse) {
            var info;
 if (sessionStorage && sessionStorage.converse) {
info = JSON.parse(sessionStorage.converse).info;
}
            if (sessionStorage && sessionStorage.converse && info.jid ) {
                converse.initialize({
                    prebind: true,
                    jid: info.jid,
                    sid: converse.getSID,
                    rid: converse.getRID,
                    allow_otr: false,
                    auto_list_rooms: false,
                    allow_muc: false,
                    auto_subscribe: true,
                    auto_reconnect: true,
                    bosh_service_url: 'https://server/http-bind',
                    debug: true,
                    hide_muc_server: true,
                    i18n: locales['en'],
                    expose_rid_and_sid: true,
                    use_otr_by_default: true,
                    show_only_online_users: true,
                    show_controlbox_by_default: true,
                    xhr_user_search: false
                                });
} else {
                converse.initialize({
                    allow_otr: false,
                    auto_list_rooms: false,
                    auto_subscribe: true,
                    bosh_service_url: 'https://server/http-bind',
                    debug: true,
                    hide_muc_server: true,
                    expose_rid_and_sid: true,
                    allow_muc: false,
                    i18n: locales['en'],
                    use_otr_by_default: true,
                    show_only_online_users: true,
                    show_controlbox_by_default: true,
                    xhr_user_search: false
                }, function() {
                    var that = this;
                    $(window).unload(function(event) {
                        if (typeof that.connection !== "undefined") {
                            sessionStorage.setItem('converse', 
JSON.stringify({info: {

jid: that.connection.jid,

rid: that.connection.rid,

sid: that.connection.sid}}));}});});}});
</script>



-----Original Message-----
From: conversejs@librelist.com [mailto:conversejs@librelist.com] On Behalf
Of JC Brand
Sent: Wednesday, September 24, 2014 11:09
To: conversejs@librelist.com
Subject: Re: [conversejs] prebind implementation w/ 0.8.3

On Wed, Sep 24, 2014 at 07:03:03AM +0000, Anton Popov wrote:
>    Hi,
> 
>    It did not change anything.. still same behavior.
> 
>    In the debug windows I see (as before)
> 
>    <body rid=”xxx” xmlns=”xxxx” sid=”xxxx”></body>
> 
>    But how do I use them?

When you set expose_sid_and_rid to true, you get the RID and SID via 
converse.getRID and converse.getSID.

Alternatively, you can also try using the "keepalive" function. 
Converse.js will then automatically keep track of the SID and RID values 
for you.

However, be aware that all the edge-cases that might appear when using 
keepalive in combination with prebind might not have been resolved.
  
>    From: conversejs@librelist.com [mailto:conversejs@librelist.com] On Behalf
>    Of Juan Chavat
>    Sent: Tuesday, September 23, 2014 17:12
>    To: conversejs@librelist.com
>    Subject: Re: [conversejs] prebind implementation w/ 0.8.3
> 
>    Hi Anton,
> 
>    You can try enabling the expose _rid_and_sid flag in the initialization
>    but take care because you can have some security issues bc of that.
> 
>    Cheers,
>    Jp
> 
> 
>    2014-09-23 9:46 GMT-03:00 Anton Popov <[1]anton.popov@iconmobile.com>:
> 
>      Hi,
> 
>      I used to have the code below but now the behavior has changed.
> 
>      It stayed logged on af ter a reload, but users were shown offline (bug
>      #175))
> 
>      I used localStorage to save the sid, jid and rid but now I only get the
>      jid. Rid and Sid do not get set.
> 
>      I can’t find the sid or rid in sessionStorage as well..
> 
>      Is there a working/official/good way of doing this?
> 
>       
> 
>      Thanks,
> 
>      Anton
> 
>       
> 
>       
> 
>       
> 
>      <html>
> 
>          <head>
> 
>              <meta charset='utf-8' />
> 
>               <meta http-equiv="Content-Type" content="text/html;
>      charset=utf-8" />
> 
>              <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
> 
>              <meta name="description" content="iconmobile web chat" />
> 
>                <link rel="stylesheet" type="text/css" media="screen"
>      href="stylesheets/stylesheet.css">
> 
>      &n bsp;       <link rel="stylesheet" type="text/css" media="screen"
>      href="[2]https://domain.com/converse/converse.min.css">
> 
>              <script src="[3]https://domain.com/c
>      onverse/converse.min.js"></script>
> 
>              <title>Converse.js</title>
> 
>          </head>
> 
>          <body>
> 
>              <div id="conversejs"></div>
> 
>          </body>
> 
>          <script>
> 
>              require(['converse'], function(converse) {
> 
>                  var info;
> 
>      if (localStorage && localStorage.co nverse) {
> 
>      info = JSON.parse(localStorage.converse).info;
> 
>      }
> 
>                 if (localStorage && localStorage.converse && info.jid 
> ) {
> 
>                      converse.initialize({
> 
>                          prebind: true,
> 
>                          jid: info.jid,
> 
>                          sid: info.sid,
> 
>                          rid: info.rid,
> 
>                          allow_otr: false,
> 
>         &nb sp;                auto_list_rooms: false,
> 
>                          allow_muc: false,
> 
>                          auto_subscribe: true,
> 
>                          auto_reconnect: true,
> 
>            &nbs p;             bosh_service_url:
>      '[4]https://domain.com/http-bind',
> 
>                          debug: true,
> 
>                          hide_muc_server: true,
> 
>                          i18n: locales['en'],
> 
>            &n bsp; &nbs p;           use_otr_by_default: true,
> 
>                          show_only_online_users: true,
> 
>                          xhr_user_search: false
> 
>                      });
> 
>                  } else {
> 
>                      converse.initialize({
> 
>                          allow_otr: false,
> 
>                  & nbsp;       auto_list_rooms: false,
> 
>                          auto_subscribe: true,
> 
>                          bosh_service_url: 
> '[5]https://domain.com/http-bind',
> 
>                 &nb sp;        debug: true,
> 
>                          hide_muc_server: true,
> 
>                          allow_muc: false,
> 
>                          i18n: locales['en'],
> 
>                          use_otr_by_default: true,
> 
>                          show_only_online_users: true,
> 
>                             xhr_user_search: false
> 
>                      }, function() {
> 
>                          var that = this;
> 
>                          $(window).unload(function(event) {
> 
>                              if (typeof that.connection !== 
> "undefined") {
> 
>                                  localStorage.setItem('converse',
>      JSON.stringify({info: {
> 
>                               &nbs
>      p;                                                      jid:
>      that.connection.jid,
> 
>

>      rid: that.connection.rid,
> 
>                                                                     
>                       sid: that.connection.sid}
> 
>      }));}});});}});
> 
>      </script>
> 
>      </html>
> 
>     
> 
> References
> 
>    Visible links
>    1. mailto:anton.popov@iconmobile.com
>    2. https://domain.com/converse/converse.min.css
>    3. https://domain.com/converse/converse.min.js
>    4. https://domain.com/http-bind
>    5. https://domain.com/http-bind

Re: [conversejs] prebind implementation w/ 0.8.3

From:
Jc Brand
Date:
2014-09-25 @ 08:53
On Wed, Sep 24, 2014 at 09:51:30AM +0000, Anton Popov wrote:
> Thanks, that worked but now after a reload I get all the users 
displayed, even the offline ones although I have show_only_online_users: 
true,

Sounds like a bug. Can you please create a ticket for it in Github?

Thanks

Re: [conversejs] prebind implementation w/ 0.8.3

From:
Anton Popov
Date:
2014-09-25 @ 10:11
https://github.com/jcbrand/converse.js/issues/233 created
thanks 

-----Original Message-----
From: conversejs@librelist.com [mailto:conversejs@librelist.com] On Behalf
Of JC Brand
Sent: Thursday, September 25, 2014 10:54
To: conversejs@librelist.com
Subject: Re: [conversejs] prebind implementation w/ 0.8.3

On Wed, Sep 24, 2014 at 09:51:30AM +0000, Anton Popov wrote:
> Thanks, that worked but now after a reload I get all the users displayed,
even the offline ones although I have show_only_online_users: true,

Sounds like a bug. Can you please create a ticket for it in Github?

Thanks