Beispiel #1
0
        public void Send(string name, string contact, string message)
        {
            string time = DateTime.Now.ToString();

            // Call the addNewMessageToPage method to update clients.
            if (contact == "All")
            {
                // we filter messages with active contacts, so it won't appear on personal chats
                Clients.All.addNewMessageToPage(name, contact, message, time);
            }

            else
            {
                var contactUser = GetContactByName(contact);
                if (contactUser?.ConnectionId != null)
                {
                    // here we have to check, if receiever is active
                    if (contactUser.ActiveContact?.Name == name)
                    {
                        Clients.Client(contactUser.ConnectionId).addNewMessageToPage(name, contact, message, time);
                    }
                }

                Clients.Caller.addNewMessageToPage(name, contact, message, time);
            }

            // save to history
            ChatData.AddMessageToHistory(name, contact, message);
        }
Beispiel #2
0
        public void Send(string name, string contact, string message)
        {
            string time = DateTime.Now.ToString();


            var contactUser = GetContactByName(contact);



            Clients.Caller.addNewMessageToPage(name, contact, message, time);
            // save to history
            ChatData.AddMessageToHistory(contact, message, name);


            message = PythonConnection(message);

            Clients.Caller.addNewMessageToPage(contact, name, message, time);
            //}
            ChatData.AddMessageToHistory(name, message, contact);
        }