Ejemplo n.º 1
0
        public async Task RequestRosterAsync()
        {
            var rosterIq = await xmppClient.RequestRosterAsync();

            var rosterItems
                = rosterIq
                  .Query
                  .Cast <Roster>()
                  .GetRoster();

            await Observable.Start(() =>
            {
                foreach (var ri in rosterItems)
                {
                    var contact = mapper.Map <Contact>(ri);

                    if (userAvatarStorage.HasUserAvatar(contact.Jid))
                    {
                        var hash            = userAvatarStorage.GetUserAvatar(contact.Jid).Hash;
                        contact.AvatarBytes = avatarStorage.GetAvatar(hash)?.ImageBytes;
                    }

                    contacts.AddOrReplace(contact, c => c.Jid == contact.Jid);
                }
            }, RxApp.MainThreadScheduler);
        }