Well, I took the leap. I moved the code so that it is evaluated when the message comes from the room. And I changed the comparison to msg.to == userJID, where the value of userJID (an instance variable) is initialized when the current user’'s presence in the room is first detected and the active flag is set to true. It works.
I also checked XEP-0045 which specifies the expected behavior to be that demonstrated by the server. It appears to me that someone got it backwards in the XIFF code … but I’'m a little puzzled how this problem could not have affected anyone else but me. Is there no one else out there that has used private messaging from within a conference?
I am a little disappointed so far with the level of support in the forums. I know this is a free product so I don’'t have a lot of latitude to complain, but I have had much better experiences with a lot of other open source (free) projects.
In any event, here is the code I changed just in case some other unfortunate soul runs across a need for it.
private function handleEvent( eventObj:Object ):void
{
switch( eventObj.type )
{
case “message”:
var msg:Message = eventObj.data;
// Check to see that the message is from this room
if( isThisRoom( msg.from ) ) {
var e:RoomEvent;
if ( msg.type == Message.GROUPCHAT_TYPE ) {
// Check for a subject change
if( msg.subject != null ) {
mySubject = msg.subject;
e = new RoomEvent(RoomEvent.SUBJECT_CHANGE);
e.subject = msg.subject;
dispatchEvent(e);
}
else {
e = new RoomEvent(RoomEvent.GROUP_MESSAGE);
e.data = msg;
dispatchEvent(e);
}
} else if ( msg.type == Message.NORMAL_TYPE ) {
try
{
var form:Array = msg.getAllExtensionsByNS(FormExtension.NS)[0];
if (form) {
e = new RoomEvent(RoomEvent.CONFIGURE_ROOM);
e.data = form;
dispatchEvent(e);
}
}
catch (e:Error)
{
trace(“Error : null trapped. Resuming.”);
}
}
// I changed the following section
// It could be a private message via the conference
else if( msg.to == userJID && msg.type == Message.CHAT_TYPE ) {
e = new RoomEvent(RoomEvent.PRIVATE_MESSAGE);
e.data = msg;
dispatchEvent(e);
}
// I changed the above section
}
// Could be an decline to a previous invite
else {
try
{
var muc:MUCUserExtension = msg.getAllExtensionsByNS(MUCUserExtension.NS)[0];
if (muc && muc.type == MUCUserExtension.DECLINE_TYPE)
{
e = new RoomEvent(RoomEvent.DECLINED);
e.from = muc.reason;
e.reason = muc.reason;
e.data = msg;
dispatchEvent(e);
}
}
catch (err:Error)
{
trace(“Error : null trapped. Resuming.”);
}
}
break;
… rest of code omitted …
I also added the following code
private function updateRoomRoster( aPresence:Presence ):void
{
try
{
var userNickname:String = aPresence.from.split( “/” )[1];
var userExts:Array = aPresence.getAllExtensionsByNS(MUCUserExtension.NS);
var item:MUCItem = userExts[0].getAllItems()[0];
var e:RoomEvent;
if ( isThisUser( aPresence.from ) ) {
myAffiliation = item.affiliation;
myRole = item.role;
if (!isActive() && aPresence.type != Presence.UNAVAILABLE_TYPE) {
//trace("Room: becoming active: " + presence.getNode());
active = true;
// I added the line below
userJID = myConnection.username + “@” + myConnection.server + “/” + myConnection.resource;
// I added the line above
e = new RoomEvent(RoomEvent.ROOM_JOIN);
dispatchEvent(e);
}
}
… rest of code omitted …
And of course, I added userJID as an instance variable in the Room class.
Bill