Not logged in. · Lost password · Register
Forum: agsXMPP SDK Support RSS
Avatar
ayyrk #1
Member since Jul 2007 · 92 posts
Group memberships: Members, Premium
Show profile · Link to this post
Subject: Multiple logins from same resource
How can I detect that a second login from the same resource has caused my connection to close?

Maybe I can check something in the onClose callback.

I need to do two things:  1) tell the user he is disconnected because another WM5 device connected with the account  2) prevent the device from automatically trying to reconnect because that is leading to a connection battle between the two devices.

Thanks!

-Ayyrk
Avatar
Alex #2
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
normally the server sends a stream error and then closes the stream which looks like the following:

  1. <stream:error>
  2.    <conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" />
  3.    <text xmlns="urn:ietf:params:xml:ns:xmpp-streams" xml:lang="en">Replaced by new connection</text>
  4. </stream:stream>

I just added a new even OnStreamError for catching this errors. I will upload the new code in some minutes to svn so you can download it and test it.

What you also can do is generate a random Resource or let the resource null. If its null then the server generates a random resource for you. If you want to allow only a single resource logged in this is of course no solution for you.

Alex
Alexander Gnauck
AG-Software
This post was edited on 2008-04-06, 12:34 by Alex.
Avatar
ayyrk #3
Member since Jul 2007 · 92 posts
Group memberships: Members, Premium
Show profile · Link to this post
Thanks, the OnStreamError event solved my problem.

-Ayyrk
Avatar
rameshkasi #4
Member since Jun 2010 · 17 posts · Location: india
Group memberships: Members
Show profile · Link to this post
In reply to post #2
Subject: restrict the second login from the same resource
Dear Alex,

I need to restrict the second login from the same resource.

I have implemented the OnStreamError handler to detect the second login. After some delay,This OnStreamError call is happening.

<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" /></stream:error>


But there is no text "Replaced by new connection" from XML. Why?

Is it possible to detect while second login without delay?

Kindly reply as soon as possible.

Thanks
Ramesh Kasi
Avatar
Alex #5
Member since Feb 2003 · 4245 posts · Location: Germany
Group memberships: Administrators, Members
Show profile · Link to this post
Quote by rameshkasi:
<stream:error xmlns:stream="http://etherx.jabber.org/streams"><conflict xmlns="urn:ietf:params:xml:ns:xmpp-streams" /></stream:error>

But there is no text "Replaced by new connection" from XML. Why?
The text is optional and can be different on each server implementation. You should rely on the conlict error type.

Apex
Alexander Gnauck
AG-Software
Close Smaller – Larger + Reply to this post:
Verification code: VeriCode Please enter the word from the image into the text field below. (Type the letters only, lower case is okay.)
Smileys: :-) ;-) :-D :-p :blush: :cool: :rolleyes: :huh: :-/ <_< :-( :'( :#: :scared: 8-( :nuts: :-O
Special characters:
Forum: agsXMPP SDK Support RSS