sstrigler/JSJaC

Inconsistency between 'onConnect' and 'connected()'

Closed this issue · 4 comments

Using JSJac 1.3.4, as best I can tell, the 'onConnect' callback in JSJacConnection is called only when login is complete and the session is established, but connected() begins returning true as soon as the initial connection has been established, at least with HttpBindingConnection. In my particular application, in order to prevent a race condition, I need to know whether the session is really established. Can either connected() be changed to reflect this, or a new method called authenticated() or sessionEstablished() or something like that be added?

I'd be happy to make the change myself but I'd have to learn github first :)

Hi!

Can you please explain what you mean when you say you need to know when a session is being established. Are you talking about BOSH sessions or XMMP session? In case of the later your requirement would be to differentiate between "XMPP session established" and "XMPP login authenticated"?

Am 25.08.2011 um 00:36 schrieb dandormont:

Using JSJac 1.3.4, as best I can tell, the 'onConnect' callback in JSJacConnection is called only when login is complete and the session is established, but connected() begins returning true as soon as the initial connection has been established, at least with HttpBindingConnection. In my particular application, in order to prevent a race condition, I need to know whether the session is really established. Can either connected() be changed to reflect this, or a new method called authenticated() or sessionEstablished() or something like that be added?

I'd be happy to make the change myself but I'd have to learn github first :)

Reply to this email directly or view it on GitHub:
#22

Hi, to be honest, I'm not entirely sure about the difference between
XMPP Session and BOSH session. What I've seen from my testing and
looking at the code is that _connected becomes true after the
"initialResponse" (again, I'm not yet clear on what this represents in
the actual flow of things) but the onconnect callback doesn't fire
until the "XMPPSessDone" or "LegacyAuthDone" (again, I'm not yet clear
on where exactly these fit in).

The issue is that in my own code, there's a packet I need to send,
specifially a presence, that I can't legally send until after the
session is fully established and (as best I understand) authenticated.
I was using connected() to determine this, but it looks like instead I
have to just set some kind of global flag in my onconnect handler and
then check this flag. This isn't a huge deal, but I was just confused
by the apparent inconsistency.

Dan

On Fri, Aug 26, 2011 at 5:34 AM, sstrigler
reply@reply.github.com
wrote:

Hi!

Can you please explain what you mean when you say you need to know when a session is being established. Are you talking about BOSH sessions or XMMP session? In case of the later your requirement would be to differentiate between "XMPP session established" and "XMPP login authenticated"?

Am 25.08.2011 um 00:36 schrieb dandormont:

Using JSJac 1.3.4, as best I can tell, the 'onConnect' callback in JSJacConnection is called only when login is complete and the session is established, but connected() begins returning true as soon as the initial connection has been established, at least with HttpBindingConnection. In my particular application, in order to prevent a race condition, I need to know whether the session is really established. Can either connected() be changed to reflect this, or a new method called authenticated()  or sessionEstablished() or something like that be added?

I'd be happy to make the change myself but I'd have to learn github first :)

Reply to this email directly or view it on GitHub:
#22

Reply to this email directly or view it on GitHub:
#22 (comment)

connected() denotes whether there is a functioning BOSH session whereas the onConnect event fires once the XMPP session is established and authenticated. So the onConnect handler is the place where you want to send your presence because it fires exactly when your allowed to send your own stuff. Actually the connected() function shouldn't have been made public and is meant for internal use. This is a bug as you mentioned yourself.

Am 26.08.2011 um 18:40 schrieb dandormont reply@reply.github.com:

Hi, to be honest, I'm not entirely sure about the difference between
XMPP Session and BOSH session. What I've seen from my testing and
looking at the code is that _connected becomes true after the
"initialResponse" (again, I'm not yet clear on what this represents in
the actual flow of things) but the onconnect callback doesn't fire
until the "XMPPSessDone" or "LegacyAuthDone" (again, I'm not yet clear
on where exactly these fit in).

The issue is that in my own code, there's a packet I need to send,
specifially a presence, that I can't legally send until after the
session is fully established and (as best I understand) authenticated.
I was using connected() to determine this, but it looks like instead I
have to just set some kind of global flag in my onconnect handler and
then check this flag. This isn't a huge deal, but I was just confused
by the apparent inconsistency.

Dan

On Fri, Aug 26, 2011 at 5:34 AM, sstrigler
reply@reply.github.com
wrote:

Hi!

Can you please explain what you mean when you say you need to know when a session is being established. Are you talking about BOSH sessions or XMMP session? In case of the later your requirement would be to differentiate between "XMPP session established" and "XMPP login authenticated"?

Am 25.08.2011 um 00:36 schrieb dandormont:

Using JSJac 1.3.4, as best I can tell, the 'onConnect' callback in JSJacConnection is called only when login is complete and the session is established, but connected() begins returning true as soon as the initial connection has been established, at least with HttpBindingConnection. In my particular application, in order to prevent a race condition, I need to know whether the session is really established. Can either connected() be changed to reflect this, or a new method called authenticated() or sessionEstablished() or something like that be added?

I'd be happy to make the change myself but I'd have to learn github first :)

Reply to this email directly or view it on GitHub:
#22

Reply to this email directly or view it on GitHub:
#22 (comment)

Reply to this email directly or view it on GitHub:
#22 (comment)

Sounds good. So I guess we can consider it as a documentation bug.

dan

On Sun, Aug 28, 2011 at 10:46 AM, sstrigler
reply@reply.github.com
wrote:

connected() denotes whether there is a functioning BOSH session whereas the onConnect event fires once the XMPP session is established and authenticated. So the onConnect handler is the place where you want to send your presence because it fires exactly when your allowed to send your own stuff. Actually the connected() function shouldn't have been made public and is meant for internal use. This is a bug as you mentioned yourself.

Am 26.08.2011 um 18:40 schrieb dandormont reply@reply.github.com:

Hi, to be honest, I'm not entirely sure about the difference between
XMPP Session and BOSH session. What I've seen from my testing and
looking at the code is that _connected becomes true after the
"initialResponse" (again, I'm not yet clear on what this represents in
the actual flow of things) but the onconnect callback doesn't fire
until the "XMPPSessDone" or "LegacyAuthDone" (again, I'm not yet clear
on where exactly these fit in).

The issue is that in my own code, there's a packet I need to send,
specifially a presence, that I can't legally send until after the
session is fully established and (as best I understand) authenticated.
I was using connected() to determine this, but it looks like instead I
have to just set some kind of global flag in my onconnect handler and
then check this flag. This isn't a huge deal, but I was just confused
by the apparent inconsistency.

Dan

On Fri, Aug 26, 2011 at 5:34 AM, sstrigler
reply@reply.github.com
wrote:

Hi!

Can you please explain what you mean when you say you need to know when a session is being established. Are you talking about BOSH sessions or XMMP session? In case of the later your requirement would be to differentiate between "XMPP session established" and "XMPP login authenticated"?

Am 25.08.2011 um 00:36 schrieb dandormont:

Using JSJac 1.3.4, as best I can tell, the 'onConnect' callback in JSJacConnection is called only when login is complete and the session is established, but connected() begins returning true as soon as the initial connection has been established, at least with HttpBindingConnection. In my particular application, in order to prevent a race condition, I need to know whether the session is really established. Can either connected() be changed to reflect this, or a new method called authenticated()  or sessionEstablished() or something like that be added?

I'd be happy to make the change myself but I'd have to learn github first :)

Reply to this email directly or view it on GitHub:
#22

Reply to this email directly or view it on GitHub:
#22 (comment)

Reply to this email directly or view it on GitHub:
#22 (comment)

Reply to this email directly or view it on GitHub:
#22 (comment)