Hey guys,
I'm working on a application within AFCS that requires all users to be connected to the same room (I have a general chat room), but then also allows users to send private messages to each other. However, as you likely know, when using a shared model, all messages get broadcast to everyone within the room, which is not the experience that I want.
I knew that SimpleChat had very similar functionality, so I dug into it a bit.
I'm going to assume that you guys ran into the same problem that I'm having because you still have commented out code in SimpleChatModel, lines 742 - 750:
/*
if ( (msgDesc.recipient is String && msgDesc.recipient != _userManager.myUserID) //it's a private but not for me
|| (msgDesc.recipient is int && msgDesc.recipient > _userManager.myUserRole) ) //it's for a role higher than mine
{
//ignore this message
//TODO: Nigel: I shouldn't be getting this at all!
return;
}
*/
After poking around for a bit, I learned that in the default_SimpleChat application on the server, if I want to send messages privately from one client to another I can set recipientDisplayName property on the ChatMessageDescriptor.
I'm guessing the solution you guys came up with is occurring on the server-side, so I ran a quick test in my console and verified that my history collection does not get updated when I send a private message.
So... the million dollar question... Is there any api or way for me to accomplish this same sort of private messaging within my own application? Is the answer just sitting there right in front of me?
P.S. -- I found it quite odd that you guys are not encoding the recipient property in your createValueObject method in ChatMessageDescriptor.as, but you are reading it. I don't really understand why you guys chose to use recipientDisplayName instead of the recipient's id, was there a reason you chose to use the display name?
/**
* @private
*/
public function readValueObject(p_valueObject:Object):void
{
displayName = p_valueObject.displayName;
msg = p_valueObject.msg;
color = p_valueObject.color;
recipient = p_valueObject.recipient;
role = p_valueObject.role;
recipientDisplayName = p_valueObject.recipientDisplayName;
}
/**
* @private
*/
public function createValueObject():Object
{
var res:Object = new Object();
res.displayName = displayName;
res.msg = msg;
res.color = color;
res.role = role;
res.recipientDisplayName = recipientDisplayName;
return res;
}