示例#1
0
        private async void SendAction()
        {
            if (string.IsNullOrWhiteSpace(Message))
            {
                return;
            }
            try
            {
                if (ChatEngine.Active == false || string.IsNullOrWhiteSpace(Username))
                {
                    ApplyAction();
                    await Task.Delay(500);

                    var ch = new ChatObject(Username, Username + " has joined");
                    await ChatEngine.Send(ch);

                    ch = new ChatObject(Username, EncryptionAlgo.Encrypt(Message, Password));
                    await ChatEngine.Send(ch);
                }
                else
                {
                    var ch = new ChatObject(Username, EncryptionAlgo.Encrypt(Message, Password));
                    await ChatEngine.Send(ch);
                }
            }catch (Exception ex)
            {
                LogDatas.Add(ex.Message);
            }
            Message = string.Empty;
        }
示例#2
0
 private void ChatEngine_MesssageReceived(object sender, ChatObject e)
 {
     try
     {
         var m = EncryptionAlgo.Decrypt(e.Message, Password);
         if (string.IsNullOrWhiteSpace(m))
         {
             LogDatas.Add(string.Format("{0}: {1}", e.From, e.Message));
         }
         else
         {
             e.Message = m;
             RoomChats.Add(e);
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         LogDatas.Add(string.Format("{0}: {1}", e.From, e.Message));
     }
 }