本文整理匯總了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.");
}
}