powered by Jive Software

Problems Creating a Room

Hello,

I am trying to create a chat room and I am having a problem. I am following some of the example code that was provided with the older version of XIFF wherein the chat room is created and then the roomname and conference server name are set … like the following.

var chatRoom = new Room(connextion);

chatRoom.roomName = “testRoom”;

chatRoom.nickname = “testNick”;

chatRoom.conferenceServer = “conference.myserver”;

I get an error when setting roomName or conferenceServer no matter what order I set them in. The problem seems to be with the following code from Room.as.

/**

  • The conference server to use for this room. Usually, this is a subdomain of

  • the primary XMPP server, like conference.myserver.com.

*/

public function get conferenceServer():String

{

return myJID.split("@")[1];

}

/**

*/

public function set conferenceServer( aServer:String ):void

{

setRoomJID(roomName + “@” + aServer);

}

/**

  • The room name that should be used when joining.

*/

public function get roomName():String

{

return myJID.split("@")[0];

}

/**

*/

public function set roomName( aName:String ):void

{

setRoomJID(aName + “@” + conferenceServer);

}

Nowhere in the code can I find where setRoomJID is called except in the setters for roomName and conferenceServer. So myJID is always null no matter which of the setters is called first. This would not be a problem except that each of the setters also references the other property causing its getter to be called … and the getter always tries to get the property by parsing (via split) the property myJID … which is always null.

I don’'t see how this could ever work, but surely someone must have chat rooms working … so what am I missing?

Bill Bailey

I tried something (kind of obvious) and it seems to have fixed the problem. I am now calling setRoomJID directly instead of using the individual properties. But I think it is a bug to expose properties that can only be used if you call some other public method first … at a minimum it is very confusing … not to mention kind of pointless since there is no reason to use the property setters once the roomname and conferenceserver have already been set.

Since the old examples worked, and as near as I can tell the code for Room.as is the same, I can only guess that ActionScript 2.0 was less picky about nulls … perhaps the getters were just returning an empty string or a null when the myJID was null. Not sure, but if it is a requirement to call setRoomJID directly, it isn’'t clear to me why the setters for the other properties have not been removed. Am I missing something here?

Bill