示例#1
0
        private async Task AddContact()
        {
            this.ReceiverAdress = this.ReceiverAdress?.Trim();

            if (!this.AlreadyClicke &&
                IotaHelper.CorrectSeedAdressChecker(this.ReceiverAdress) &&
                this.ReceiverAdress?.Length == 81 &&
                this.ReceiverAdress != this.user.PublicKeyAddress)
            {
                this.IsBusy        = true;
                this.AlreadyClicke = true;
                try
                {
                    // get information from receiver adress
                    var trytes  = this.user.TangleMessenger.GetMessages(this.ReceiverAdress);
                    var contact = IotaHelper.FilterRequestInfos(trytes);

                    if (contact?.PublicNtruKey != null && contact.ContactAdress != null)
                    {
                        // faster than generating adresses
                        var requestContact = new Contact()
                        {
                            ChatAdress      = Seed.Random().ToString(),
                            Name            = this.user.Name,
                            ImageUrl        = this.user.ImageUrl,
                            ContactAdress   = this.user.ApprovedAddress,
                            Request         = true,
                            Rejected        = false,
                            PublicNtruKey   = null,
                            PublicKeyAdress = this.user.PublicKeyAddress
                        };

                        // encrypt contact request? too much infos needed here for one message needs to get request adress plus chatadress
                        await this.user.TangleMessenger.SendJsonMessageAsync(new SentDataWrapper <Contact> {
                            Data = requestContact, Sender = this.user.Name
                        }, contact.ContactAdress);
                    }
                }
                catch
                {
                    this.DisplayInvalidAdressPrompt();
                }
            }
            else
            {
                this.DisplayInvalidAdressPrompt();
            }

            this.IsBusy        = false;
            this.AlreadyClicke = false;
        }
示例#2
0
        public ChatViewModel(Contact contact, User user)
        {
            this.ntruKex = new NtruKex();

            this.profileImageUrl = contact.ImageUrl;
            this.user            = user;
            this.contact         = contact;

            var trytes       = this.user.TangleMessenger.GetMessages(this.contact.PublicKeyAdress);
            var contactInfos = IotaHelper.FilterRequestInfos(trytes);

            contact.PublicNtruKey = contactInfos.PublicNtruKey;

            this.Messages = new ObservableCollection <MessageViewModel>();

            this.GetMessagesAsync(this.Messages);

            this.OutGoingText = null;
            this.SendCommand  = new Command(async() => { await this.SendMessage(); });
        }