Snippets: Msnp - GroupShowAll

// SOCKSArmor Snippets - MSNP.
// Author: Felipe Kellermann <felipek@socksarmor.org>
// Revision: $Revision: 5395 $
// Date: $Date: 2008-01-03 18:05:06 -0200 (Thu, 03 Jan 2008) $
//
// This snippet shows a listing of all the groups with its members.

using System;
using SocksArmor;
using SocksArmor.Plugins.Msnp;

class SocksArmorSnippet
{
    static void Main(string[] args)
    {
        // Remote SOCKSArmor server.
        RemoteServer server = new RemoteServer();
        server.Connect("127.0.0.1", 10842, "username", "password");

        // Msnp plugin interface.
        MsnpPlugin msnp = server.Plugins["msnp"].Interface as MsnpPlugin;

        // GroupObjects is a collection of group objects on the server.
        foreach (MsnpGroup group in msnp.Objects.GroupObjects) {
            Console.WriteLine("Person: {0}", group);
            Console.WriteLine("  Description: {0}", group.Description);
            Console.WriteLine("  Members: {0}", group.Count);

            // MsnpGroup has an enumerator that returns a collection of
            // all the group's "members" and each member is represented
            // by the base class MsnpObjectBase.
            foreach (MsnpObjectBase member in group)
                Console.WriteLine("    Member: {0}", member);
        }

        server.Disconnect();
    }
}