本文整理汇总了C#中WhatsAppApi.Helper.ProtocolTreeNode.GetAllChildren方法的典型用法代码示例。如果您正苦于以下问题:C# ProtocolTreeNode.GetAllChildren方法的具体用法?C# ProtocolTreeNode.GetAllChildren怎么用?C# ProtocolTreeNode.GetAllChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WhatsAppApi.Helper.ProtocolTreeNode
的用法示例。
在下文中一共展示了ProtocolTreeNode.GetAllChildren方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeNotificationPicture
private static void TypeNotificationPicture(ProtocolTreeNode tmpChild, string tmpFrom)
{
foreach (ProtocolTreeNode item in (tmpChild.GetAllChildren() ?? new ProtocolTreeNode[0]))
{
if (ProtocolTreeNode.TagEquals(item, "set"))
{
string photoId = item.GetAttribute("id");
if (photoId != null)
{
//this.EventHandler.OnPhotoChanged(tmpFrom, item.GetAttribute("author"), photoId);
WhatsEventHandler.OnPhotoChangedEventHandler(tmpFrom, item.GetAttribute("author"), photoId);
}
}
else if (ProtocolTreeNode.TagEquals(item, "delete"))
{
//this.EventHandler.OnPhotoChanged(tmpFrom, item.GetAttribute("author"), null);
WhatsEventHandler.OnPhotoChangedEventHandler(tmpFrom, item.GetAttribute("author"), null);
}
}
}
示例2: handleNotification
protected void handleNotification(ProtocolTreeNode node)
{
if (!String.IsNullOrEmpty(node.GetAttribute("notify")))
{
this.fireOnGetContactName(node.GetAttribute("from"), node.GetAttribute("notify"));
}
string type = node.GetAttribute("type");
switch (type)
{
case "picture":
ProtocolTreeNode child = node.children.FirstOrDefault();
this.fireOnNotificationPicture(child.tag,
child.GetAttribute("jid"),
child.GetAttribute("id"));
break;
case "status":
ProtocolTreeNode child2 = node.children.FirstOrDefault();
this.fireOnGetStatus(node.GetAttribute("from"),
child2.tag,
node.GetAttribute("notify"),
System.Text.Encoding.UTF8.GetString(child2.GetData()));
break;
case "subject":
//fire username notify
this.fireOnGetContactName(node.GetAttribute("participant"),
node.GetAttribute("notify"));
//fire subject notify
this.fireOnGetGroupSubject(node.GetAttribute("from"),
node.GetAttribute("participant"),
node.GetAttribute("notify"),
System.Text.Encoding.UTF8.GetString(node.GetChild("body").GetData()),
GetDateTimeFromTimestamp(node.GetAttribute("t")));
break;
case "contacts":
//TODO
break;
case "participant":
string gjid = node.GetAttribute("from");
string t = node.GetAttribute("t");
foreach (ProtocolTreeNode child3 in node.GetAllChildren())
{
if (child3.tag == "add")
{
this.fireOnGetParticipantAdded(gjid,
child3.GetAttribute("jid"),
GetDateTimeFromTimestamp(t));
}
else if (child3.tag == "remove")
{
this.fireOnGetParticipantRemoved(gjid,
child3.GetAttribute("jid"),
child3.GetAttribute("author"),
GetDateTimeFromTimestamp(t));
}
else if (child3.tag == "modify")
{
this.fireOnGetParticipantRenamed(gjid,
child3.GetAttribute("remove"),
child3.GetAttribute("add"),
GetDateTimeFromTimestamp(t));
}
}
break;
}
this.SendNotificationAck(node);
}
示例3: handleIq
protected void handleIq(ProtocolTreeNode node)
{
if (node.GetAttribute("type") == "error")
{
this.fireOnError(node.GetAttribute("id"), node.GetAttribute("from"), Int32.Parse(node.GetChild("error").GetAttribute("code")), node.GetChild("error").GetAttribute("text"));
}
if (node.GetChild("sync") != null)
{
//sync result
ProtocolTreeNode sync = node.GetChild("sync");
ProtocolTreeNode existing = sync.GetChild("in");
ProtocolTreeNode nonexisting = sync.GetChild("out");
//process existing first
Dictionary<string, string> existingUsers = new Dictionary<string, string>();
if (existing != null)
{
foreach (ProtocolTreeNode child in existing.GetAllChildren())
{
existingUsers.Add(System.Text.Encoding.UTF8.GetString(child.GetData()), child.GetAttribute("jid"));
}
}
//now process failed numbers
List<string> failedNumbers = new List<string>();
if (nonexisting != null)
{
foreach (ProtocolTreeNode child in nonexisting.GetAllChildren())
{
failedNumbers.Add(System.Text.Encoding.UTF8.GetString(child.GetData()));
}
}
int index = 0;
Int32.TryParse(sync.GetAttribute("index"), out index);
this.fireOnGetSyncResult(index, sync.GetAttribute("sid"), existingUsers, failedNumbers.ToArray());
}
if (node.GetAttribute("type").Equals("result", StringComparison.OrdinalIgnoreCase)
&& node.GetChild("query") != null
)
{
//last seen
DateTime lastSeen = DateTime.Now.AddSeconds(double.Parse(node.children.FirstOrDefault().GetAttribute("seconds")) * -1);
this.fireOnGetLastSeen(node.GetAttribute("from"), lastSeen);
}
if (node.GetAttribute("type").Equals("result", StringComparison.OrdinalIgnoreCase)
&& (node.GetChild("media") != null || node.GetChild("duplicate") != null)
)
{
//media upload
this.uploadResponse = node;
}
if (node.GetAttribute("type").Equals("result", StringComparison.OrdinalIgnoreCase)
&& node.GetChild("picture") != null
)
{
//profile picture
string from = node.GetAttribute("from");
string id = node.GetChild("picture").GetAttribute("id");
byte[] dat = node.GetChild("picture").GetData();
string type = node.GetChild("picture").GetAttribute("type");
if (type == "preview")
{
this.fireOnGetPhotoPreview(from, id, dat);
}
else
{
this.fireOnGetPhoto(from, id, dat);
}
}
if (node.GetAttribute("type").Equals("get", StringComparison.OrdinalIgnoreCase)
&& node.GetChild("ping") != null)
{
this.SendPong(node.GetAttribute("id"));
}
if (node.GetAttribute("type").Equals("result", StringComparison.OrdinalIgnoreCase)
&& node.GetChild("group") != null)
{
//group(s) info
List<WaGroupInfo> groups = new List<WaGroupInfo>();
foreach (ProtocolTreeNode group in node.children)
{
groups.Add(new WaGroupInfo(
group.GetAttribute("id"),
group.GetAttribute("owner"),
group.GetAttribute("creation"),
group.GetAttribute("subject"),
group.GetAttribute("s_t"),
group.GetAttribute("s_o")
));
}
this.fireOnGetGroups(groups.ToArray());
}
if (node.GetAttribute("type").Equals("result", StringComparison.OrdinalIgnoreCase)
&& node.GetChild("participant") != null)
{
//group participants
List<string> participants = new List<string>();
foreach (ProtocolTreeNode part in node.GetAllChildren())
{
if (part.tag == "participant" && !string.IsNullOrEmpty(part.GetAttribute("jid")))
{
participants.Add(part.GetAttribute("jid"));
//.........这里部分代码省略.........
示例4: TypeSubject
/// <summary>
/// Type subject
/// </summary>
/// <param name="messageNode"></param>
/// <param name="tmpFrom"></param>
/// <param name="uJid"></param>
/// <param name="tmpId"></param>
/// <param name="tmpT"></param>
private void TypeSubject(ProtocolTreeNode messageNode, string tmpFrom, string uJid, string tmpId, string tmpT)
{
bool flag = false;
foreach (ProtocolTreeNode item in messageNode.GetAllChildren("request"))
{
if (item.GetAttribute("xmlns").Equals("urn:xmpp:receipts"))
{
flag = true;
}
}
ProtocolTreeNode child = messageNode.GetChild("body");
string subject = (child == null) ? null : WhatsApp.SYSEncoding.GetString(child.GetData());
if (subject != null)
{
WhatsEventHandler.OnGroupNewSubjectEventHandler(tmpFrom, uJid, subject, int.Parse(tmpT, CultureInfo.InvariantCulture));
}
if (flag)
{
this.sendHandler.SendSubjectReceived(tmpFrom, tmpId);
}
}
示例5: TypeNotification
/// <summary>
/// Notify typing
/// </summary>
/// <param name="messageNode">The protocoltreenode</param>
/// <param name="tmpAttrFrom">From?</param>
/// <param name="tmpAttrbId">Message id</param>
private void TypeNotification(ProtocolTreeNode messageNode, string tmpAttrFrom, string tmpAttrbId)
{
foreach (ProtocolTreeNode tmpChild in (messageNode.GetAllChildren() ?? new ProtocolTreeNode[0]))
{
if (ProtocolTreeNode.TagEquals(tmpChild, "notification"))
{
string tmpChildType = tmpChild.GetAttribute("type");
if (StringComparer.Ordinal.Equals(tmpChildType, "picture"))
{
TypeNotificationPicture(tmpChild, tmpAttrFrom);
}
}
else if (ProtocolTreeNode.TagEquals(tmpChild, "request"))
{
this.sendHandler.SendNotificationReceived(tmpAttrFrom, tmpAttrbId);
}
}
}
示例6: TypeError
/// <summary>
/// Type error
/// </summary>
/// <param name="messageNode"></param>
/// <param name="tmpAttrbId"></param>
/// <param name="tmpAttrFrom"></param>
private void TypeError(ProtocolTreeNode messageNode, string tmpAttrbId, string tmpAttrFrom)
{
int num2 = 0;
foreach (ProtocolTreeNode node in messageNode.GetAllChildren("error"))
{
string tmpCode = node.GetAttribute("code");
try
{
num2 = int.Parse(tmpCode, CultureInfo.InvariantCulture);
}
catch (Exception)
{
}
}
if ((tmpAttrFrom != null) && (tmpAttrbId != null))
{
FMessage.Key key = new FMessage.Key(tmpAttrFrom, true, tmpAttrbId);
}
}
示例7: TypeChat
/// <summary>
/// Notify typing chat
/// </summary>
/// <param name="messageNode"></param>
/// <param name="tmpAttrFrom"></param>
/// <param name="tmpAttrbId"></param>
/// <param name="builder"></param>
/// <param name="tmpAttrFromJid"></param>
private void TypeChat(ProtocolTreeNode messageNode, string tmpAttrFrom, string tmpAttrbId, FMessage.Builder builder, string tmpAttrFromJid)
{
foreach (ProtocolTreeNode itemNode in (messageNode.GetAllChildren() ?? new ProtocolTreeNode[0]))
{
if (ProtocolTreeNode.TagEquals(itemNode, "composing"))
{
WhatsEventHandler.OnIsTypingEventHandler(tmpAttrFrom, true);
}
else if (ProtocolTreeNode.TagEquals(itemNode, "paused"))
{
WhatsEventHandler.OnIsTypingEventHandler(tmpAttrFrom, false);
}
else if (ProtocolTreeNode.TagEquals(itemNode, "body") && (tmpAttrbId != null))
{
string dataString = WhatsApp.SYSEncoding.GetString(itemNode.GetData());
var tmpMessKey = new FMessage.Key(tmpAttrFrom, false, tmpAttrbId);
builder.Key(tmpMessKey).Remote_resource(tmpAttrFromJid).NewIncomingInstance().Data(dataString);
}
else if (ProtocolTreeNode.TagEquals(itemNode, "media") && (tmpAttrbId != null))
{
long tmpMediaSize;
int tmpMediaDuration;
builder.Media_wa_type(FMessage.GetMessage_WA_Type(itemNode.GetAttribute("type"))).Media_url(
itemNode.GetAttribute("url")).Media_name(itemNode.GetAttribute("file"));
if (long.TryParse(itemNode.GetAttribute("size"), WhatsConstants.WhatsAppNumberStyle,
CultureInfo.InvariantCulture, out tmpMediaSize))
{
builder.Media_size(tmpMediaSize);
}
string tmpAttrSeconds = itemNode.GetAttribute("seconds");
if ((tmpAttrSeconds != null) &&
int.TryParse(tmpAttrSeconds, WhatsConstants.WhatsAppNumberStyle, CultureInfo.InvariantCulture, out tmpMediaDuration))
{
builder.Media_duration_seconds(tmpMediaDuration);
}
if (builder.Media_wa_type().HasValue && (builder.Media_wa_type().Value == FMessage.Type.Location))
{
double tmpLatitude = 0;
double tmpLongitude = 0;
string tmpAttrLatitude = itemNode.GetAttribute("latitude");
string tmpAttrLongitude = itemNode.GetAttribute("longitude");
if ((tmpAttrLatitude == null) || (tmpAttrLongitude == null))
{
tmpAttrLatitude = "0";
tmpAttrLongitude = "0";
}
else if (!double.TryParse(tmpAttrLatitude, WhatsConstants.WhatsAppNumberStyle, CultureInfo.InvariantCulture, out tmpLatitude) ||
!double.TryParse(tmpAttrLongitude, WhatsConstants.WhatsAppNumberStyle, CultureInfo.InvariantCulture, out tmpLongitude))
{
throw new CorruptStreamException("location message exception parsing lat or long attribute: " + tmpAttrLatitude + " " + tmpAttrLongitude);
}
builder.Latitude(tmpLatitude).Longitude(tmpLongitude);
string tmpAttrName = itemNode.GetAttribute("name");
string tmpAttrUrl = itemNode.GetAttribute("url");
if (tmpAttrName != null)
{
builder.Location_details(tmpAttrName);
}
if (tmpAttrUrl != null)
{
builder.Location_url(tmpAttrUrl);
}
}
if (builder.Media_wa_type().HasValue && (builder.Media_wa_type().Value) == FMessage.Type.Contact)
{
ProtocolTreeNode tmpChildMedia = itemNode.GetChild("media");
if (tmpChildMedia != null)
{
builder.Media_name(tmpChildMedia.GetAttribute("name")).Data(WhatsApp.SYSEncoding.GetString(tmpChildMedia.GetData()));
}
}
else
{
string tmpAttrEncoding = itemNode.GetAttribute("encoding") ?? "text";
if (tmpAttrEncoding == "text")
{
builder.Data(WhatsApp.SYSEncoding.GetString(itemNode.GetData()));
}
}
var tmpMessageKey = new FMessage.Key(tmpAttrFrom, false, tmpAttrbId);
builder.Key(tmpMessageKey).Remote_resource(tmpAttrFromJid).NewIncomingInstance();
}
else if (ProtocolTreeNode.TagEquals(itemNode, "request"))
{
builder.Wants_receipt(true);
}
//.........这里部分代码省略.........