本文整理汇总了C#中agsXMPP.protocol.client.IQ.ToString方法的典型用法代码示例。如果您正苦于以下问题:C# IQ.ToString方法的具体用法?C# IQ.ToString怎么用?C# IQ.ToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agsXMPP.protocol.client.IQ
的用法示例。
在下文中一共展示了IQ.ToString方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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.");
}
}