Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > BOOK: Professional XMPP Programming with JavaScript and jQuery
|
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 April 9th, 2011, 11:56 AM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default [Chapter 6] Searching for a specific chat user ...

I am working my way through the book (big fan of!) and have come across a scenario in the "Gab" app that I have not been able to figure out. I would like to limit the roster of available users to chat with to a list of users matching a certain criteria, say, email address, user name, etc ...

I modified the reference to jabber:iq:roster to use jabber:iq:search in Gab.js:

From:
var iq = $iq({type: 'get'}).c('query', {xmlns: 'jabber:iq:roster'});

To:
var iq = $iq({to: "vjud.our_url", type: "set"})
.c("query", {xmlns: "jabber:iq:search"})
.c("x", {xmlns: "jabber:x:data", type: "submit"})
.c("field", {var: "user"})
.c("value", 'smith*');

I then reload the page, but do not receive any search results. I submitted the following via the "Peek" app and the expected search results were returned:

<iq to='vjud.our_url' type='set' xmlns='jabber:client'>
<query xmlns='jabber:iq:search'>
<x xmlns='jabber:x:data' type='submit'>
<field var='user'><value>smith*</value></field>
</x>
</query>
</iq>

I'm wondering if there is a parameter of some sort that I am missing? Does anyone have any ideas or advice?

Thanks
 
Old April 18th, 2011, 07:49 PM
Wrox Author
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

jabber:iq:search was created for jabber user directory services, which aren't commonly deployed these days. You can't directly query the remote roster as you are trying.

What you can do is store the roster when you request it and then write your own function which returns jids matching a pattern. Of course, this won't work for searching by email address, as the server won't know them.
 
Old April 18th, 2011, 07:50 PM
Wrox Author
 
Join Date: Jan 2010
Posts: 178
Thanks: 0
Thanked 16 Times in 15 Posts
Default

To do email searches you could query the vcards of everyone in the roster, which may have the user's personal information including emails, but only if they've set their vcard.
 
Old April 19th, 2011, 08:27 AM
Registered User
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for the replies! Good to know that I was trying to use the jabber:iq:search incorrectly. Pattern matching on jid's seems like a workable solution. Thanks much!





Similar Threads
Thread Thread Starter Forum Replies Last Post
multi user chat badinar BOOK: Professional XMPP Programming with JavaScript and jQuery 2 January 17th, 2011 08:12 PM
Create user in a specific role arnab-jit BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 1 June 23rd, 2009 09:59 AM
Searching for a user in Active Directory with ASP Ricapar Classic ASP Professional 1 July 15th, 2008 11:07 PM
How do after i login it will display specific user PHP FAQs 0 July 20th, 2006 08:06 PM
View recordset for the specific user mikersantiago Classic ASP Basics 4 October 20th, 2004 10:19 AM





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