Wrox Programmer Forums
| 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 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 January 15th, 2011, 01:28 AM
Authorized User
 
Join Date: Jan 2011
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default presence without jquery

i get the following error "StropheError message: Cannot queue non-DOMElement." when i construct the presence message without using jquery and send it. any reason why?

thanks.

var Connection_ = null;
function Connect()
{
Connection_ = new Strophe.Connection('http://localhost:5280/xmpp-httpbind');

Connection_.connect(user, pwd, XMPP_ConnectionHandler);
}


function XMPP_ConnectionHandler(status)
{
if (status === Strophe.Status.CONNECTED)
{
var presence = "<presence>";
presence += " <priority>-1</priority>";
presence += "</presence>";
Connection_.send(presence);
}

}
 
Old January 17th, 2011, 01:52 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 cannot pass arbitrary strings to send(). They must be DOM elements. You can use Strophe's xmlElement() function to generate these if you like, or use the Strophe builder stuff.

For example:

Code:
Connection_.send($presence().c('priority').t(1));
would do the same thing your code is trying to do.

If you want to see how these DOM elements are built behind the scenes, you can look at the strophe.js source.
 
Old January 17th, 2011, 08:20 PM
Authorized User
 
Join Date: Jan 2011
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i was just playing around with a things and found that

$presence().c('priority').t(1) and the string that i have on the code above is the exact same string and yet did produce the same result.

i did some digging of strophe source code and saw the initialization that happen when the $<> code is called.

thanks for answering the post. feels very good that there is someone to look out for when i need help...




Similar Threads
Thread Thread Starter Forum Replies Last Post
problem getting the online presence list after attaching anamaria BOOK: Professional XMPP Programming with JavaScript and jQuery 2 December 5th, 2010 01:24 PM
Dealing with the presence of an XML tag rather tha Mike250 SQL Server 2005 1 June 6th, 2008 03:50 PM
How to Test for Presence of a File BrianWren Visual Basic 2005 Basics 7 April 30th, 2008 05:44 PM
Testing for presence of a variable rushman XSLT 2 September 12th, 2007 10:36 AM
How to check for the presence of an attribute dsekar_nat XSLT 2 July 27th, 2006 05:04 AM





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