Example #1
0
            void DumpDataToConsole(LWTSD.DataController.DataPage Page)
            {
                foreach (var Resource in Page.Data)
                {
                    LWTSD.ResourceTypes.ResourceInteger RInt = Resource as LWTSD.ResourceTypes.ResourceInteger;

                    if (RInt != null)
                    {
                        Console.WriteLine("{0} = {1}", Resource.Path, RInt.Value);
                        continue;
                    }

                    LWTSD.ResourceTypes.ResourceString RString = Resource as LWTSD.ResourceTypes.ResourceString;
                    if (RString != null)
                    {
                        Console.WriteLine("{0} = {1}", Resource.Path, RString.Value);
                        continue;
                    }

                    LWTSD.ResourceTypes.ResourceBoolean RBoolean = Resource as LWTSD.ResourceTypes.ResourceBoolean;
                    if (RBoolean != null)
                    {
                        Console.WriteLine("{0} = {1}", Resource.Path, RBoolean.Value);
                        continue;
                    }

                    LWTSD.ResourceTypes.ResourceDouble RDouble = Resource as LWTSD.ResourceTypes.ResourceDouble;
                    if (RDouble != null)
                    {
                        Console.WriteLine("{0} = {1}", Resource.Path, RDouble.Value);
                        continue;
                    }
                }
            }
Example #2
0
            public ExampleStorageEntity()
            {
                string CertPath = "../../../YOURCERTHERE.pfx";
                var    Cert     = new System.Security.Cryptography.X509Certificates.X509Certificate2(CertPath);

                Uplink = new Connection("164.138.24.100",
                                        5222,
                                        new JID("", "sandbox.clayster.com", ""),
                                        "",
                                        Cert,
                                        true, 30, 0);

                Uplink.Roster.OnSubscribe    = Roster_OnSubscribe;
                Uplink.Roster.OnUnsubscribed = Roster_OnUnsubscribed;

                Uplink.OnConnectionStateChanged += Uplink_OnConnectionStateChanged;
                Uplink.Connect();

                while (DataStorage == null)
                {
                    Thread.Sleep(10);
                }

                // Set claim key
                string MyClaimKey = Cert.GetCertHashString();
                var    awaiter    = DataStorage.SessionController.SetClaimKey(MyClaimKey);

                awaiter.Wait();
                Console.WriteLine("Set claim key to {0} = {1}", awaiter.Result, MyClaimKey);

                CPUUsage               = new LWTSD.ResourceTypes.ResourceInteger();
                CPUUsage.Path          = "meters/cpuusage";
                CPUUsage.Displayname   = "CPU%";
                CPUUsage.SupportsRead  = true;
                CPUUsage.SupportsWrite = false;
                CPUUsage.Unit          = "percentage";
                CPUUsage.Value         = 0;

                AvailableMemory               = new LWTSD.ResourceTypes.ResourceInteger();
                AvailableMemory.Path          = "meters/availablememory";
                AvailableMemory.Displayname   = "Available Memory";
                AvailableMemory.SupportsRead  = true;
                AvailableMemory.SupportsWrite = false;
                AvailableMemory.Unit          = "MB";
                AvailableMemory.Value         = 0;

                ScratchPad               = new LWTSD.ResourceTypes.ResourceString();
                ScratchPad.Path          = "misc/scratchpad";
                ScratchPad.Displayname   = "Scratchad";
                ScratchPad.SupportsRead  = true;
                ScratchPad.SupportsWrite = true;
                ScratchPad.Value         = "Nothing";

                DataStorage.AddResource(CPUUsage);
                DataStorage.AddResource(AvailableMemory);
                DataStorage.AddResource(ScratchPad);
                DataStorage.RegisterResources().Wait();

                UpdateResourcesTimer           = new System.Timers.Timer(1000.0);
                UpdateResourcesTimer.AutoReset = true;
                UpdateResourcesTimer.Elapsed  += (sender, e) => { UpdateResources(); };
                UpdateResourcesTimer.Start();
            }