private void SendMessageCommandAction()
		{
			var message = new Message
			{
				Body = MessageBody,
				ReceiverId = _contactId,
				DateSent = QryptoTime.GetTime
			};
			MakeApiCallAsync(() => _messageService.TrySendMessage(message), success =>
			{
				if (!success)
				{
					_helper.ShowRequestFailedPopup("Something went wrong when message was being sent. Please try again later");
					return;
				}
				MessageBody = string.Empty;
				Messages.Add(new StoredMessage
				{
					Body = message.Body,
					Date =  message.DateSent,
					Sent = true
				});
			});
		}
Esempio n. 2
0
 public bool TrySendMessage(Message message)
 {
     var encMsg = _encryptionService.Encrypt(message.Body, message.ReceiverId);
     var success = _client.TrySendMessage(new Message
     {
         Body = encMsg.Body,
         DateSent = message.DateSent,
         Iv = encMsg.Iv,
         SenderId = message.SenderId,
         ReceiverId = message.ReceiverId,
         SymmetricKey = encMsg.SymmetricKey,
         DigitalSignature = encMsg.DigitalSignature
     });
     if(success)
         _storageService.SaveMessages(new[] {new MessageItem
         {
             Body = message.Body,
             Date = message.DateSent,
             ReceiverId = message.ReceiverId,
             SenderId = message.SenderId
         } });
     return success;
 }
 public bool TrySendMessage(Message message)
 {
     return TryExecute(
         new RestRequest(
             $"{ApiUris.SendMessage}{_sessionId}",
             HttpMethod.Post
         )
         .AddJsonBody(message)
     );
 }