当前位置: 首页>>代码示例>>C#>>正文


C# IQ.HasTag方法代码示例

本文整理汇总了C#中agsXMPP.protocol.client.IQ.HasTag方法的典型用法代码示例。如果您正苦于以下问题:C# IQ.HasTag方法的具体用法?C# IQ.HasTag怎么用?C# IQ.HasTag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在agsXMPP.protocol.client.IQ的用法示例。


在下文中一共展示了IQ.HasTag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnIq

        void OnIq(object sender, IQ iq)
        {
            if (iq.HasTag("oa"))
            {
                if (iq.InnerXml.Contains("errorcode=\"200\""))
                {
                    const string identityRegEx = "identity=([A-Z0-9]{8}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{4}-[A-Z0-9]{12}):status";
                    var regex = new Regex(identityRegEx, RegexOptions.IgnoreCase | RegexOptions.Singleline);
                    var match = regex.Match(iq.InnerXml);
                    if (match.Success)
                    {
                        _sessionToken = match.Groups[1].ToString();
                    }

                    Wait = false;
                }
            }
        }
开发者ID:slavikko,项目名称:harmony,代码行数:18,代码来源:HarmonyAuthenticationClient.cs

示例2: OnIqResponseHandler

        /// <summary>
        ///     Lookup the TaskCompletionSource for the IQ message and try to set the result.
        /// </summary>
        /// <param name="sender">object</param>
        /// <param name="iq">IQ</param>
        private void OnIqResponseHandler(object sender, IQ iq)
        {
            Debug.WriteLine("Received event " + iq.Id);
            Debug.WriteLine(iq.ToString());
            TaskCompletionSource<IQ> resulTaskCompletionSource;
            if ((iq.Id != null) && _resultTaskCompletionSources.TryGetValue(iq.Id, out resulTaskCompletionSource))
            {
                // Error handling from XMPP
                if (iq.Error != null)
                {
                    var errorMessage = iq.Error.ErrorText;
                    Debug.WriteLine(errorMessage);
                    resulTaskCompletionSource.TrySetException(new Exception(errorMessage));
                    // Result task is longer needed in the lookup
                    _resultTaskCompletionSources.Remove(iq.Id);
                    return;
                }

                // Message processing (error handling)
                if (iq.HasTag("oa"))
                {
                    var oaElement = iq.SelectSingleElement("oa");

                    // Check error code
                    var errorCode = oaElement.GetAttribute("errorcode");
                    // 100 -> continue
                    if ("100".Equals(errorCode))
                    {
                        // Ignoring 100 continue
                        Debug.WriteLine("Ignoring, expecting more to come.");

                        // TODO: Insert code to handle progress updates for the startActivity
                    }
                    // 200 -> OK
                    else if ("200".Equals(errorCode))
                    {
                        resulTaskCompletionSource.TrySetResult(iq);

                        // Result task is longer needed in the lookup
                        _resultTaskCompletionSources.Remove(iq.Id);
                    }
                    else
                    {
                        // We didn't get a 100 or 200, this must mean there was an error
                        var errorMessage = oaElement.GetAttribute("errorstring");
                        Debug.WriteLine(errorMessage);
                        // Set the exception on the TaskCompletionSource, it will be picked up in the await
                        resulTaskCompletionSource.TrySetException(new Exception(errorMessage));

                        // Result task is longer needed in the lookup
                        _resultTaskCompletionSources.Remove(iq.Id);
                    }
                }
                else
                {
                    Debug.WriteLine("Unexpected content");
                }
            }
            else
            {
                Debug.WriteLine("No matching result task found.");
            }
        }
开发者ID:Lakritzator,项目名称:harmony,代码行数:68,代码来源:HarmonyClient.cs

示例3: GetData

 /// <summary>
 ///     Get the data from the IQ response object
 /// </summary>
 /// <param name="iq">IQ response object</param>
 /// <returns>string with the data of the element</returns>
 private string GetData(IQ iq)
 {
     if (iq.HasTag("oa"))
     {
         var oaElement = iq.SelectSingleElement("oa");
         // Keep receiving messages until we get a 200 status
         // Activity commands send 100 (continue) until they finish
         var errorCode = oaElement.GetAttribute("errorcode");
         if ("200".Equals(errorCode))
         {
             return oaElement.GetData();
         }
     }
     return null;
 }
开发者ID:Lakritzator,项目名称:harmony,代码行数:20,代码来源:HarmonyClient.cs

示例4: OnIq

        /// <summary>
        /// Fires on receipt of an Iq message from the HarmonyHub
        /// Check ClientCommandType to determine what to do
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="iq"></param>
        void OnIq(object sender, IQ iq)
        {
            if (iq.HasTag("oa"))
            {
                // Keep receiving messages until we get a 200 status
                // Activity commands send 100 (continue) until they finish
                if (iq.InnerXml.Contains("errorcode=\"200\""))
                {
                    const string identityRegEx = "\">(.*)</oa>";
                    var regex = new Regex(identityRegEx, RegexOptions.IgnoreCase | RegexOptions.Singleline);

                    switch (_clientCommand)
                    {
                        case ClientCommandType.GetConfig:
                            {
                                var match = regex.Match(iq.InnerXml);
                                if (match.Success)
                                {
                                    Config = match.Groups[1].ToString();
                                }
                            }
                            break;
                        case ClientCommandType.GetCurrentActivity:
                            {
                                var match = regex.Match(iq.InnerXml);
                                if (match.Success)
                                {
                                    CurrentActivity = match.Groups[1].ToString().Split('=')[1];
                                }
                            }
                            break;
                        case ClientCommandType.PressButton:
                            {
                                var match = regex.Match(iq.InnerXml);
                                if (match.Success)
                                {
                                }
                            }
                            break;
                        case ClientCommandType.StartActivity:
                            break;
                    }

                    Wait = false;
                }
            }
        }
开发者ID:slavikko,项目名称:harmony,代码行数:53,代码来源:HarmonyClient.cs


注:本文中的agsXMPP.protocol.client.IQ.HasTag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。