private void NewTextMessage(string name, string msg, MessageType mt, Aes aes) { if (mt == MessageType.Unicast) { ChatMessage cm = new ChatMessage { Author = name, Message = AesEnc.DecryptStringAes(msg, aes.Key, aes.IV), Time = DateTime.Now }; //todo: receive encrypted message and decrypt var sender = _participants.Where((u) => string.Equals(u.Name, name)).FirstOrDefault(); ctxTaskFactory.StartNew(() => sender.Chatter.Add(cm)).Wait(); if (!(SelectedParticipant != null && sender.Name.Equals(SelectedParticipant.Name))) { ctxTaskFactory.StartNew(() => sender.HasSentNewMessage = true).Wait(); } } }
public async Task SendUnicastTextMessageAsync(string recepient, string msg, Aes aes) { await hubProxy.Invoke("UnicastTextMessage", new object[] { recepient, AesEnc.EncryptStringAes(msg, aes.Key, aes.IV), aes }); //todo: Encryption happens here }