public bool removeMessage(Friend friend, byte[] msg_id) { lock (pendingRecipients) { PendingRecipient pending_recipient = pendingRecipients.Find(x => x.address.SequenceEqual(friend.walletAddress)); if (pending_recipient != null) { PendingMessageHeader tmp_msg_header = pending_recipient.messageQueue.Find(x => x.id.SequenceEqual(msg_id)); if (tmp_msg_header != null) { pending_recipient.messageQueue.Remove(tmp_msg_header); if (File.Exists(tmp_msg_header.filePath)) { File.Delete(tmp_msg_header.filePath); return(true); } } } return(false); } }
private void sendMessage(OffloadedMessage om) { PendingMessage pm = new PendingMessage(om.msg, om.sendToServer, om.sendPushNotification, om.removeAfterSending); StreamMessage msg = pm.streamMessage; PendingMessageHeader tmp_msg_header = tmp_msg_header = getPendingMessageHeader(om.friend, msg.id); if (tmp_msg_header != null) { pm.filePath = tmp_msg_header.filePath; } PendingRecipient tmp_recipient = null; lock (pendingRecipients) { tmp_recipient = pendingRecipients.Find(x => x.address.SequenceEqual(msg.recipient)); if (tmp_recipient == null) { tmp_recipient = new PendingRecipient(msg.recipient); pendingRecipients.Add(tmp_recipient); } } if (om.addToPendingMessages) { pm.save(storagePath); if (tmp_msg_header == null) { tmp_recipient.messageQueue.Add(new PendingMessageHeader() { filePath = pm.filePath, id = pm.streamMessage.id, sendToServer = pm.sendToServer }); } } if (tmp_recipient.messageQueue.Count == 1 || !om.addToPendingMessages) { sendMessage(om.friend, pm, om.addToPendingMessages); } }