Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > BOOK: Professional XMPP Programming with JavaScript and jQuery
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 15th, 2013, 02:50 AM
Authorized User
Points: 182, Level: 3
Points: 182, Level: 3 Points: 182, Level: 3 Points: 182, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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: my__registered_jabberid@jabber.org/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?
  #2 (permalink)  
Old June 16th, 2013, 01:12 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

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.
  #3 (permalink)  
Old June 16th, 2013, 05:40 PM
Authorized User
Points: 182, Level: 3
Points: 182, Level: 3 Points: 182, Level: 3 Points: 182, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by metajack View Post
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?
  #4 (permalink)  
Old June 16th, 2013, 07:07 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

If you supply only the domain portion (ie, "jabber.org" instead of "foo@jabber.org") 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.
  #5 (permalink)  
Old June 16th, 2013, 09:20 PM
Authorized User
Points: 182, Level: 3
Points: 182, Level: 3 Points: 182, Level: 3 Points: 182, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by metajack View Post
If you supply only the domain portion (ie, "jabber.org" instead of "foo@jabber.org") 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?
  #6 (permalink)  
Old August 8th, 2013, 01:20 PM
Wrox Author
Points: 702, Level: 10
Points: 702, Level: 10 Points: 702, Level: 10 Points: 702, Level: 10
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

No, you don't need a password in that case.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XMPP performance on using common jid sudhansu BOOK: Professional XMPP Programming with JavaScript and jQuery 4 November 26th, 2012 12:41 AM
Bare JID & too many resources tiracu BOOK: Professional XMPP Programming with JavaScript and jQuery 1 September 21st, 2010 06:39 PM
Choosing first or second element sunrain XSLT 4 November 8th, 2006 09:31 AM
choosing directories joconnor PHP How-To 0 August 11th, 2004 09:12 AM
Choosing a database rbmese Visual C++ 3 August 9th, 2004 08:19 AM



All times are GMT -4. The time now is 06:57 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.