本文整理汇总了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;
}
}
}
示例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.");
}
}
示例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;
}
示例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;
}
}
}