本文整理匯總了C#中agsXMPP.protocol.client.Presence.SelectSingleElement方法的典型用法代碼示例。如果您正苦於以下問題:C# Presence.SelectSingleElement方法的具體用法?C# Presence.SelectSingleElement怎麽用?C# Presence.SelectSingleElement使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類agsXMPP.protocol.client.Presence
的用法示例。
在下文中一共展示了Presence.SelectSingleElement方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: OnPresence
private void OnPresence(Client client, Presence presence)
{
var clientContext = SessionModel.GetClientContext(client);
if (clientContext.Jid.Equals(presence.From, new CaseInsensitiveComparer()))
{
return;
}
var vcardUpdate = presence.SelectSingleElement<VcardUpdate>();
if (vcardUpdate == null)
{
return;
}
if (string.IsNullOrEmpty(vcardUpdate.Photo))
{
return;
}
var bare = presence.From.Bare.ToLower();
var hash = vcardUpdate.Photo;
var key = Tuple.Create(bare, hash);
if (_pendingReuests.ContainsKey(key))
{
return;
}
if (_dataProvider.HasPhoto(bare, hash))
{
return;
}
var jid = presence.From.ToString().ToLower();
InitiateRequest(client, key, jid);
}
示例2: OnPresence
private void OnPresence(Presence presence)
{
if (presence.MucUser != null)
{
return;
}
if (presence.Error != null)
{
EventError eventError = new EventError(string.Format("Presence error from {0}", presence.From),
presence.Error);
Events.Instance.OnEvent(this, eventError);
}
else
{
Capabilities capabilities = presence.SelectSingleElement(typeof (Capabilities)) as Capabilities;
switch (presence.Type)
{
case PresenceType.subscribe:
case PresenceType.subscribed:
case PresenceType.unsubscribe:
case PresenceType.unsubscribed:
{
OnSubscribePresence(presence);
break;
}
default:
{
OnContactPresence(presence, capabilities);
break;
}
}
}
}