 |
BOOK: Professional XMPP Programming with JavaScript and jQuery  | This is the forum to discuss the Wrox book Professional XMPP Programming with JavaScript and jQuery by Jack Moffitt; ISBN: 978-0-470-54071-8 |
|
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Professional XMPP Programming with JavaScript and jQuery section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

June 15th, 2013, 02:50 AM
|
|
Authorized User
|
|
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Can one assign a jid resource of their choosing?
Hello people,
I'm creating a lil multiplayer online game app and I'm using XMPP to send stanzas to all other player when one player makes a move. Currently, I'm using my registered jid to connect each player to the network and relying on the automatically assigned resource to identify each player. So each player's full jid looks something like this: [email protected]/automatically_assigned_resource
This obviously has its limitations not the least of which is the problem of reconnecting a player again if they lose their internet connection momentarily. Who knows a better way of doing this? Is it possible for example to assign a resource to a user upon connection (say for example using their unique username), in place of the automatically assigned resource?
|
|

June 16th, 2013, 01:12 PM
|
|
Wrox Author
|
|
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
|
|
You shouldn't be reusing one bare JID for N players. Each player should get their own JID.
That said, if you want to connect with a specific full JID, just give the full JID to connect() instead of the bare JID. It will try to use the resource specified when it does resource binding. Note that some servers (notably Gmail, not aware of any others that do this) always give you a random resource, although it might be prefixed with the thing you asked for. In other words, a server should normally honor your requested resource, but in some cases will still assign you a different one.
|
|

June 16th, 2013, 05:40 PM
|
|
Authorized User
|
|
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by metajack
You shouldn't be reusing one bare JID for N players. Each player should get their own JID.
That said, if you want to connect with a specific full JID, just give the full JID to connect() instead of the bare JID. It will try to use the resource specified when it does resource binding. Note that some servers (notably Gmail, not aware of any others that do this) always give you a random resource, although it might be prefixed with the thing you asked for. In other words, a server should normally honor your requested resource, but in some cases will still assign you a different one.
|
Thanks matajack. Points duly noted. I can imagine a million reasons why it wouldn't be advisable to use the same jid for multiple users. But then I'm not sure how jids can be automatically created for end users. Is there a way that can be automatically done without making them go through the trouble of creating their own jid?
|
|

June 16th, 2013, 07:07 PM
|
|
Wrox Author
|
|
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
|
|
If you supply only the domain portion (ie, "jabber.org" instead of " [email protected]") to connect(), this will log in with SASL ANONYMOUS, which will randomly assign you a JID. Obviously, osme state is lost on log out, like roster and chat rooms, etc, but that state is probably not useful in your situation since you are sharing it N ways currently.
Collecta used this method since we didn't much care about accounts. At Chesspark, we just had people create accounts and made it as simple as possible via normal web form.
|
|

June 16th, 2013, 09:20 PM
|
|
Authorized User
|
|
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
Originally Posted by metajack
If you supply only the domain portion (ie, "jabber.org" instead of " [email protected]") to connect(), this will log in with SASL ANONYMOUS, which will randomly assign you a JID. Obviously, osme state is lost on log out, like roster and chat rooms, etc, but that state is probably not useful in your situation since you are sharing it N ways currently.
Collecta used this method since we didn't much care about accounts. At Chesspark, we just had people create accounts and made it as simple as possible via normal web form.
|
So you're one of the developers? Don't even know where to start thanking your for the good work you guys do... Just one more thing, if I only supply the domain portion, I wouldn't need a password, would I?
|
|

August 8th, 2013, 01:20 PM
|
|
Wrox Author
|
|
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
|
|
No, you don't need a password in that case.
|
|
 |