Skip to main content
Participant
July 22, 2008
Question

Private Messages

  • July 22, 2008
  • 1 reply
  • 270 views
In the following function I am trying to send a message directly to a recipient (toWhom parameter = client.user.userName) as a private message, but cannot resolve how to do so...any suggestions/hints?
I have tried several conditional loops, but am wholly unsuccessful...


quote:

Code
VideoConference.prototype.deliverMessage = function(client, msg, toWhom)
{
var now = new Date();
this.startTime = now.getTime();
var str = now.getHours() + ":";
var mins = now.getMinutes();
str += (mins>=10) ? mins : "0"+mins

if (toWhom == "everyone")
{
//Public
this.history_s.send("appendMessage", " { " + client.ip +" } " + client.user.userName+" @ "+ str + " : " + msg);
this.messages_so.send("showMessage", " { " + client.ip +" } " + client.user.userName+" @ "+ str + " : " + msg);
return;
}
else if (toWhom != "everyone")
{
//Private
this.messages_so.send("showMessage", " { " + client.ip +" } " + client.user.userName+" @ "+ str + " : " + msg);
return;
}
}

    This topic has been closed for replies.

    1 reply

    July 31, 2008
    Correct me if I'm wrong, but it looks like in either case (public or private) you're calling thes ame this.messages_so.send("showMessage").

    What I don't see here is any way for the receiving client to see that it's a private message. If every client is subscribing to the messages_so shared object then they'll all receive this and execute the showMessage function. Perhaps you could just write data to a shared object with the userID of the client to whom it's addressed as the name, and the message as the value, then listen for onChange events on the client side and display messages addressed to that user's ID.