Contact list, aka roster

In XMPP the contact list, aka buddy listâ„¢ is called roster. After your connection succeeded you can request the roster from the server with the following code:

Request and enumerate the contact list

// request the roster from the server
var rosterIqResult = await xmppClient.RequestRosterAsync();

// get all rosterItems (list of contacts)
var rosterItems
    = rosterIqResult
        .Query
        .Cast<Roster>()
        .GetRoster();

// enumerate over the items and build your contact list or GUI
foreach (var ri in rosterItems)
{
    // we use AutoMapper here to map the XMPP
    // rosterItem to our Contact ViewModel
    var contact = mapper.Map<Contact>(ri);    
    contacts.AddOrReplace(contact, c => c.Jid == contact.Jid);

    // Dump some info
    Console.WriteLine($"Jid: {ri.Jid}");
    Console.WriteLine($"Name: {ri.Name}");
}