Beispiel #1
0
 internal VLMessageRecipient()
 {
     m_message          = default(Int32);
     m_recipient        = default(Int64);
     m_attributeFlags   = default(Int16);
     m_errorCount       = default(Int16);
     m_sendDT           = null;
     m_status           = default(Byte);
     m_collectorPayment = null;
     m_isCharged        = false;
 }
        //Checks the recipient status of the message (based on all participants, ie. READ meaning at least one has read)
        private MessageRecipientStatus _GetMessageStatus(IMessage msg)
        {
            if (msg == null || msg.Sender == null || msg.Sender.UserId == null)
            {
                return(MessageRecipientStatus.Pending);
            }

            //If we didn't send the message, we already know the status - we have read it
            if (!msg.Sender.UserId.Equals(MainActivity.GetUserID(), System.StringComparison.InvariantCultureIgnoreCase))
            {
                return(MessageRecipientStatus.Read);
            }

            //Assume the message has been sent
            MessageRecipientStatus status = MessageRecipientStatus.Sent;

            //Go through each user to check the status, in this case we check each user and
            // prioritize so
            // that we return the highest status: Sent -> Delivered -> Read
            var allParticipants = MainActivity.GetAllParticipants();

            for (int i = 0; i < allParticipants.Count; i++)
            {
                //Don't check the status of the current user
                string participant = allParticipants[i];
                if (participant.Equals(MainActivity.GetUserID(), System.StringComparison.InvariantCultureIgnoreCase))
                {
                    continue;
                }

                if (status == MessageRecipientStatus.Sent)
                {
                    if (msg.GetRecipientStatus(participant) == MessageRecipientStatus.Delivered)
                    {
                        status = MessageRecipientStatus.Delivered;
                    }

                    if (msg.GetRecipientStatus(participant) == MessageRecipientStatus.Read)
                    {
                        return(MessageRecipientStatus.Read);
                    }
                }
                else if (status == MessageRecipientStatus.Delivered)
                {
                    if (msg.GetRecipientStatus(participant) == MessageRecipientStatus.Read)
                    {
                        return(MessageRecipientStatus.Read);
                    }
                }
            }

            return(status);
        }
Beispiel #3
0
        public MessageRecipient(BinaryReader bR)
        {
            switch (bR.ReadByte()) //version
            {
            case 1:
                _userId      = new BinaryNumber(bR.BaseStream);
                _status      = (MessageRecipientStatus)bR.ReadByte();
                _deliveredOn = bR.ReadDate();
                break;

            default:
                throw new InvalidDataException("Cannot decode data format: version not supported.");
            }
        }
        public MessageRecipient(Stream s)
        {
            BincodingDecoder decoder = new BincodingDecoder(s);

            switch (decoder.DecodeNext().GetByteValue()) //version
            {
            case 1:
                _name        = decoder.DecodeNext().GetStringValue();
                _status      = (MessageRecipientStatus)decoder.DecodeNext().GetByteValue();
                _deliveredOn = decoder.DecodeNext().GetDateTimeValue();
                break;

            default:
                throw new InvalidDataException("Cannot decode data format: version not supported.");
            }
        }
Beispiel #5
0
 public void SetDeliveredStatus()
 {
     _status      = MessageRecipientStatus.Delivered;
     _deliveredOn = DateTime.UtcNow;
 }