Esempio n. 1
0
        /// <summary>
        /// Send message to HarmonyHub to request Configuration.
        /// Result is parsed by OnIq based on ClientCommandType
        /// </summary>
        public void GetConfig()
        {
            EnsureConnection();

            var iqToSend = new IQ {
                Type = IqType.get, Namespace = "", From = "1", To = "guest"
            };

            iqToSend.AddChild(HarmonyDocuments.ConfigDocument());
            iqToSend.GenerateId();

            var iqGrabber = new IqGrabber(Xmpp);
            var iq        = iqGrabber.SendIq(iqToSend, 10000);

            if (iq != null)
            {
                var match = IdentityRegex.Match(iq.InnerXml);
                if (match.Success)
                {
                    RawConfig = match.Groups[1].ToString();
                    Config    = null;
                    try
                    {
                        Config = new JavaScriptSerializer().Deserialize <HarmonyConfigResult>(RawConfig);
                    }
                    catch { }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        ///     Request the configuration from the hub
        /// </summary>
        /// <returns>HarmonyConfig</returns>
        public async Task <Config> GetConfigAsync()
        {
            var iq = await RequestResponseAsync(HarmonyDocuments.ConfigDocument()).ConfigureAwait(false);

            var config = GetData(iq);

            if (config != null)
            {
                return(Serializer.FromJson <Config>(config));
            }
            throw new Exception("No data found");
        }
Esempio n. 3
0
        /// <summary>
        /// Send message to HarmonyHub to request Configuration.
        /// Result is parsed by OnIq based on ClientCommandType
        /// </summary>
        public void GetConfig()
        {
            _clientCommand = ClientCommandType.GetConfig;

            var iqToSend = new IQ {
                Type = IqType.get, Namespace = "", From = "1", To = "guest"
            };

            iqToSend.AddChild(HarmonyDocuments.ConfigDocument());
            iqToSend.GenerateId();

            var iqGrabber = new IqGrabber(Xmpp);

            iqGrabber.SendIq(iqToSend, 10);

            WaitForData(5);
        }
Esempio n. 4
0
File: Client.cs Progetto: tihilv/Vkm
        /// <summary>
        ///     Request the configuration from the hub
        /// </summary>
        /// <returns>HarmonyConfig</returns>
        public async Task <Config> GetConfigAsync()
        {
            Trace.WriteLine("Harmony-logs: GetConfigAsync");
            Trace.WriteLine("Harmony: Fetching configuration...");

            var iq = await SendDocumentAsync(HarmonyDocuments.ConfigDocument()).ConfigureAwait(false);

            Trace.WriteLine("Harmony: Parsing configuration...");
            var rawConfig = GetData(iq.ResultIQ);

            if (rawConfig != null)
            {
                Config config = Serializer.FromJson <Config>(rawConfig);
                Trace.WriteLine("Harmony: Ready");
                return(config);
            }
            throw new Exception("Harmony: Configuration not found");
        }