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
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 25th, 2014, 08:01 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
Cool How to handle joining a chat room

I've been splitting hairs, trying to accomplish what I though would be simple and straight forward (writing a handler which triggers an action once a user joins a chat room).

So here's the line for joining the chat room
Code:
My_namespace.connection.send(
			
$pres({to:  My_namespace.room_jid + "/" + My_namespace.nick, id: "join_room"}).c("jid").t(My_namespace.jid).up().c("nick").t(My_namespace.nick)
			
);
And here is the line that sets the handler before initial presence is sent

Code:
My_namespace.connection.addHandler(My_namespace.room_joined, null, "presence", null, "join_room");

And here's the handler implementation

Code:
		My_namespace.room_joined = function(presence){
	
		
			var nick = $(presence).children("nick").text();
			
			var jid = $(presence).children("jid").text();
		
                        console.log("Successfully joined room.  Nick is: "+nick+" and jid is: "+jid );

			return true;
		
		}

This doesn't work. I suspected that you cannot use ids with such stanzas. So i stripped the id attribute and tried this instead, similar to what's in the book

Code:
		My_namespace.room_joined = function(presence){


			var from = $(presence).attr("from");
			
			
			if(from === My_namespace.room_jid + "/" + My_namespace.nick){//If presence is coming from me
				
			     var nick = $(presence).children("nick").text();
			
			     var jid = $(presence).children("jid").text();
		
                        console.log("Successfully joined room.  Nick is: "+nick+" and jid is: "+jid );

                        }


			return true;
		
		}
This kind of works, but only when I test it on the iPhone. For some reason I do not understand, it either won't run on a pc or mac, or it just takes for ever to trigger the handler. Who knows how to best go about this?
 


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
Chat Room aliusmankhan ASP.NET 2.0 Professional 2 August 23rd, 2008 07:51 AM
GUI chat room mralam Java GUI 4 October 30th, 2007 04:46 AM
Online Chat Room pro-logic .NET Web Services 0 October 20th, 2003 05:26 AM
Chat Room Creation HELP! nvillare Classic ASP Basics 2 August 28th, 2003 06:46 AM
Chat Room Trouble nvillare Classic ASP Basics 0 July 11th, 2003 03:58 PM



All times are GMT -4. The time now is 09:54 PM.


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