Snippets: SocksArmor - StatisticsGet

// SOCKSArmor Snippets - SocksArmor.
// 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 the access of a statistic variable as a regular
// variable on the server's blackboard.  Note that, as a regular type
// of statistic variable, its value gets zeroed from time to time.

using System;
using SocksArmor;

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

        // Note the use of "generics" to get the value.  Here the
        // indication of the type is explicit.  Outputs the value
        // returned from the server.
        int managementThreads = server.Variables.GetValue<int>("stats-management-threads");
        Console.WriteLine("Management Threads: {0}", managementThreads);

        server.Disconnect();
    }
}