Wrox Programmer Forums
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
Old June 10th, 2010, 11:10 AM
Registered User
Join Date: Jun 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default ch06 source code bug

In the jid_to_id function in chapter 6 there is a line:


which only creates a usable id for servers with 0 or 1 full stops in the name. For a more general approach it should be


I have multiple djabberd vhosts running and they all have 2 or 3 full stops in the name; it took me a while to figure out why all of my contacts were always marked offline.
Old June 10th, 2010, 05:10 PM
Wrox Author
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts

Thanks for the tip. Another reader caught this as well, and this (and probably a few other minor fixes) are available in the GitHub repo at http://github.com/metajack/profxmpp
Old December 29th, 2011, 05:52 PM
Registered User
Join Date: Dec 2011
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts

Came here to point out this problem – my fault for not checking carefully through all the threads first!

It would be better if the wrox ‘dowload code’ link went to the GIT repo as I just assumed it must be the most recent from the official site.

The issue makes the example unusable when your xmpp server hostname is an IP address. As '.' is an illegal attribute character it adds a new tab each time on_message is called as $('#chat-' + jid_id).length always resolves to 0.

As a slight improvement you could use:

.replace(/[.@]/g, "-") 
to replace all the characters with one call to replace

or safer:
.replace(/[^\w]/g, "-")
to protect against usernames with illegal attribute chars in like tes^t@xmpphost.com

Last edited by frozeng; December 29th, 2011 at 05:55 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
A small problem with the code from CH06 and with next ones. Jeremie BOOK: ASP.NET 3.5 Enterprise Application Development with Visual Studio 2008: Problem Design Solutio 2 February 15th, 2009 07:40 AM
a big bug on a code busteronline ASP.NET 1.0 and 1.1 Basics 0 September 15th, 2008 09:11 AM
Bug in the Poll VB code? thuyvncr BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 2 April 21st, 2007 08:43 PM
ch06-xmldistilled not open humayunlalzad BOOK: Beginning XML 3rd Edition 3 February 13th, 2007 09:35 AM
Dataview bug? or code error.. nyar C# 1 November 20th, 2006 03:03 PM

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