public void Send()
 {
     var message = new Message { From = Initiator, Value = Message };
     SendMessage(this, null);
     Conversation.Add(message);
     Message = String.Empty;
 }
Ejemplo n.º 2
0
 public ContactViewModel(User user, Message message, ContactViewModel parent)
 {
     User = user;
     IsOnline = user.Online;
     Status = user.Online ? "Online" : "Offline";
     _parent = parent;
     Message = message;
 }
Ejemplo n.º 3
0
 public void AddMessage(Message message, User initiator)
 {
     ChatSessionViewModel chatSession;
     if (!_chatSessions.TryGetValue(message.From, out chatSession))
     {
         chatSession = StartNewSession(message.Initiator, initiator);
         chatSession.OpenChat();
     }
     chatSession.MessageReceived(message);
 }
 public void AddMessage(Message message, User initiator)
 {
     if (_chatSessions.SingleOrDefault(c => c.User.Name == message.From.Name) == null)
     {
         StartNewSession(message.From, initiator);
         _chatSessions.SingleOrDefault(c => c.User.Name == message.From.Name).MessageReceived(message);
     }
     else
     {
         _chatSessions.SingleOrDefault(c => c.User.Name == message.From.Name).MessageReceived(message);
     }
 }
Ejemplo n.º 5
0
 public Task<Message> SendMessage(string userName, Message message)
 {
     return _chat.Invoke<Message>("Send", userName, message);
 }
Ejemplo n.º 6
0
 public void SaveMessage(Message message)
 {
     _chat.Invoke<Message>("SaveMessage", message);
 }
Ejemplo n.º 7
0
 private void OnMessage(Message message)
 {
     // Starts a new conversation with message.From if not started,
     // otherwise, it will add a message to the conversation window with message.From.
     _chatSessions.AddMessage(message, Me.User);
 }
Ejemplo n.º 8
0
 private void OnMessage(Message message)
 {
     // Starts a new conversation with message.From if not started,
     // otherwise, it will add a message to the conversation window with message.From.
 }
Ejemplo n.º 9
0
 public void Send()
 {
     SendMessage(this, new ChatSessionEventArgs(this.Contact, this.Message));
     var message = new Message { From = Initiator, Value = Message, IsMine = true, DateReceived = DateTime.Now };
     Conversation.Add(message);
     Message = String.Empty;
 }
Ejemplo n.º 10
0
 public ChatSessionEventArgs(User user, Message message)
 {
     Contact = user;
     Message = message;
 }
Ejemplo n.º 11
0
 public void AddMessage(Message message)
 {
     Conversation.Add(message);
 }
Ejemplo n.º 12
0
 public void Send()
 {
     var message = new Message { From = Initiator.Name, Initiator = Initiator, To = Contact.Name, Contact = Contact, Value = Message, IsMine = true, DateReceived = DateTime.Now };
     SendMessage(this, new ChatSessionEventArgs(Contact, message));
     Conversation.Add(message);
     Message = String.Empty;
 }
 public void MessageReceived(Message message)
 {
     Conversation.Add(message);
 }
Ejemplo n.º 14
0
        public void Send(string who, Message message)
        {
            EnsureAuthented();

            List<string> connections;
            if (_userConnections.TryGetValue(who, out connections))
            {
                // Get a list of connections for the user we want to send a message to
                foreach (var id in connections)
                {
                    // Send a message to each user, and tell them who it came from
                    Clients[id].addMessage(new Message
                    {
                        From = Context.User.Identity.Name,
                        Initiator = GetUser(Context.User.Identity.Name),
                        Value = message.Value
                    });
                }
            }
        }
Ejemplo n.º 15
0
 public void SaveMessage(Message message)
 {
     _db.Add(message);
     _db.CommitChanges();
 }
Ejemplo n.º 16
0
 public void MessageReceived(Message message)
 {
     message.DateReceived = DateTime.Now;
     Conversation.Add(message);
 }
Ejemplo n.º 17
0
 public void Add(Message message)
 {
     _db.Messages.Add(message);
     _db.SaveChanges();
 }