Discussion list for Unity developers.
unity-dev at moock.org
Thu Aug 9 18:26:57 CDT 2007
Thanks for the response colin!
Have it working now. I thought it was much more involved than that after
looking at the uClientChatDemo files - feeling a bit sheepish. =]
Anyway, I also wanted to include who the message was from, so I just added a
sender parameter that is passed to the privateMessage method, and just grabs
the username of the sending client:
var sender:String =
getRemoteClientManager().getClient(getClientID()).getAttribute(null,
"username");
invokeOnClient("privateMessage",
getTargetMC().chatpanel.users.getSelectedItem().data, pMsg, sender);
public function privateMessage(clientID:String, msg:String,
sender:String):Void {
...
}
Cheers,
drew
----- Original Message -----
From: "Discussion list for Unity developers." <unity-dev at moock.org>
To: <unity-dev at moock.org>
Sent: Wednesday, August 08, 2007 9:12 AM
Subject: Re: ||unity-dev|| uAvatarChat: private messages?
> hi drew,
>
> The following code uses invokeOnClient() to send a private message from
> one client to another. The method invoked remotely on the target client
> is privateMessage(). Here, the client ID is hard coded as "25" but in a
> real application it would normally be retrieved programmatically,
> perhaps from the user's selection in a client list or from user-entered
> text.
>
> var recipientClientID:String = "25";
> theUClient.invokeOnClient("privateMessage", recipientClientID, msg);
>
> And here is the privateMessage() method, defined in a UClient subclass.
>
> public function privateMessage (clientID:String, message:String):Void {
> this.chatField_txt.text += "Private message: " + message);
> }
>
> Here's another example privateMessage() method that forwards the call to
> ChatRoom.privateMessage() for processing. ChatRoom is a URoom subclass
> that implements the logical response to a private message.
>
> public function privateMessage (clientID:String, message:String):Void {
> // Retrieve a list of rooms that this client is in.
> var rooms:Array =
> getRemoteClientManager().getClient(getClientID()).getRoomIDs();
> // Send the private message to all rooms this client is in.
> for (var i:Number = rooms.length; --i >= 0; ) {
> // Cast to ChatRoom.
>
> ChatRoom(getRoomManager().getRoom(rooms[i])).privateMessage(clientID,
> message);
> }
> }
>
> colin
>
> Discussion list for Unity developers. wrote:
>> Hi All,
>>
>> I am currently working on extending uAvatarChat with several features.
>> I've had some success, but I've encountered some problems too. I'm trying
>> to implement private messages in the chat. I've been looking at the
>> documentation on method invokeOnClient(), and I understand that I must
>> use this to call a 'privateMessage' method... I'm confused where to go
>> from here though - what does the privateMessage function need to do in
>> order to get the message to the incoming textfield of (only) the intended
>> client? I've had a look at the uClientChat demo files, but I'm still
>> confused with the steps that are taken from when the message is sent to
>> when it is received, and how to get this working in uAvatarChat. Could
>> anyone help with an explanation or some advice on how I could implement
>> this?
>>
>> Thanks,
>>
>> drew
>> --
>> you're a unity-dev subscriber. to unsubscribe, visit
>> www.moock.org/mailman/listinfo/unity-dev/
>>
>> superb hosting for this list and moock.org is generously provided by
>> Rackspace. See: http://www.rackspace.com/?supbid=moock
> --
> you're a unity-dev subscriber. to unsubscribe, visit
> www.moock.org/mailman/listinfo/unity-dev/
>
> superb hosting for this list and moock.org is generously provided by
> Rackspace. See: http://www.rackspace.com/?supbid=moock