This Question is Answered (go to answer)

2 "helpful" answers available (5 pts)
2,636 Views 9 Replies Last post: Aug 21, 2008 1:30 PM by Philip Double RSS
Mike Chambers Bronze 13 posts since
Aug 13, 2008
Currently Being Moderated

Aug 14, 2008 11:06 AM

Simple Example of Joining a Room?

Does anyone have a simple example of joining a room? assuming that I know the room name?

 

Also, are there any docs for the project? All I can find are the old AS2 docs, which appear to be out of date.

 

mike

Mitchell Hashimoto Bronze 7 posts since
Aug 7, 2008
Currently Being Moderated
Aug 14, 2008 2:46 PM in response to: Mike Chambers
Re: Simple Example of Joining a Room?

I've been working with XIFF quite a bit lately, but here is an example:

 

 

xmpp = new XMPPSocketConnection();
room = new Room(xmpp);
xmpp.username = "username";
xmpp.password = "password";
xmpp.server   = "jabber.server.com";
xmpp.connect("standard");

 

 

Then after receiving the login event:

 

 

room.roomJID = new JID("someroom@conference.jabber.server.com");
room.join();

 

 

Then that will fire a RoomEvent.ROOM_JOIN on a successful connect.

Mitchell Hashimoto Bronze 7 posts since
Aug 7, 2008
Currently Being Moderated
Aug 14, 2008 2:22 PM in response to: Mike Chambers
Re: Simple Example of Joining a Room?

public function join( createReserved:Boolean = false, joinPresenceExtensions:Array = null ):Boolean

 

Notice the "= false" and "= null" ?

 

They are optional arguments. Just leave them blank.

Mitchell Hashimoto Bronze 7 posts since
Aug 7, 2008
Currently Being Moderated
Aug 14, 2008 2:46 PM in response to: Mike Chambers
Re: Simple Example of Joining a Room?

Oh! I'm so sorry! I posted the wrong code... Here you go

 

 

room.roomJID = new JID("default@conference.jabber.citrusbyte.com");
room.join();

 

EDIT: I also edited my above post to fix this...

Philip Double Bronze 14 posts since
Jul 23, 2008
Currently Being Moderated
Aug 20, 2008 6:51 AM in response to: Mike Chambers
Re: Simple Example of Joining a Room?

Hi Mitchel,

I saw the advice that you gave to Mike Chambers and was hoping that  you'd be able to expand upon that a bit if you have a moment.  In  creating a chat room in the way that you outlined does indeed create a  room but all entries in the room are attributed to the JID...

For instance, if I create a chat room called  allchat@conference.jabber.org, log several users in, all of their input  shows up like:

allchat [14:33] : what up?
allchat [14:33] : not much just waiting for the dealeo to begin....
allchat [14:34] : but how do I add my username instead of this crap....


How do I go about having different users enter a room as themselves?  I.E. if I have a user named 'billybob' and a user named 'philisajerk'  how do I get the output to appear like:

philisajerk [14:33] : what up?
billybob[14:33] : not much just waiting for the dealeo to begin....
philisajerk[14:34] : but how do I add my username instead of this crap....

 

The code that I'm using to create the room after establishing a connection and logging in is as follows:

room= new Room(connection);
room.roomJID = new JID("allchat@conference.example.com");
room.addEventListener(RoomEvent.ROOM_JOIN, onRoomJoin);
room.join();

Any input would be appreciated because this is driving me bonkers....

Thanks,
Phil

Juga Paazmaya Bronze 55 posts since
Oct 23, 2007
Currently Being Moderated
Aug 21, 2008 1:23 PM in response to: Philip Double
Re: Simple Example of Joining a Room?

The message.type will detemine if the message is for a room or for a private chat.

Use this with Message.GROUPCHAT_TYPE to see whether a message is for a room.

Then according to that information you can get the nickname from the JID.

 

            var user:String = from.node;
            if (message.type == Message.GROUPCHAT_TYPE) {
             &n bsp;   user = from.resource;
            }

 

The situation is also explained here:

http://paazio.nanbudo.fi/tutorials/flash/xiff-chat-part-3-chat-room

Philip Double Bronze 14 posts since
Jul 23, 2008
Currently Being Moderated
Aug 21, 2008 1:30 PM in response to: Juga Paazmaya
Re: Simple Example of Joining a Room?

Thank you very much! I actually wound up writing a parser last night to get the proper name to show but this is exactly what I was looking for and will switch to it....

 

XIFF seems like a great project - just wish that it had more documentation...

 

BTW: Your examples have been VERY helpful - thank you for providing them.

 

Thank you,

Phil

More Like This

  • Retrieving data ...

Bookmarked By (0)