• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Helper.ProtocolTreeNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WhatsAppApi.Helper.ProtocolTreeNode的典型用法代码示例。如果您正苦于以下问题:C# ProtocolTreeNode类的具体用法?C# ProtocolTreeNode怎么用?C# ProtocolTreeNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ProtocolTreeNode类属于WhatsAppApi.Helper命名空间,在下文中一共展示了ProtocolTreeNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UploadFile

        protected WaUploadResponse UploadFile(string b64hash, string type, long size, byte[] fileData, string to, string contenttype, string extension)
        {
            ProtocolTreeNode media = new ProtocolTreeNode("media", new KeyValue[] {
                new KeyValue("hash", b64hash),
                new KeyValue("type", type),
                new KeyValue("size", size.ToString())
            });
            string id = TicketManager.GenerateId();
            ProtocolTreeNode node = new ProtocolTreeNode("iq", new KeyValue[] {
                new KeyValue("id", id),
                new KeyValue("to", WhatsConstants.WhatsAppServer),
                new KeyValue("type", "set"),
                new KeyValue("xmlns", "w:m")
            }, media);
            this.uploadResponse = null;
            this.SendNode(node);
            int i = 0;
            while (this.uploadResponse == null && i <= 10)
            {
                i++;
                this.pollMessage();
            }
            if (this.uploadResponse != null && this.uploadResponse.GetChild("duplicate") != null)
            {
                WaUploadResponse res = new WaUploadResponse(this.uploadResponse);
                this.uploadResponse = null;
                return res;
            }
            else
            {
                try
                {
                    string uploadUrl = this.uploadResponse.GetChild("media").GetAttribute("url");
                    this.uploadResponse = null;

                    Uri uri = new Uri(uploadUrl);

                    string hashname = string.Empty;
                    byte[] buff = MD5.Create().ComputeHash(System.Text.Encoding.Default.GetBytes(b64hash));
                    StringBuilder sb = new StringBuilder();
                    foreach (byte b in buff)
                    {
                        sb.Append(b.ToString("X2"));
                    }
                    hashname = String.Format("{0}.{1}", sb.ToString(), extension);

                    string boundary = "zzXXzzYYzzXXzzQQ";

                    sb = new StringBuilder();

                    sb.AppendFormat("--{0}\r\n", boundary);
                    sb.Append("Content-Disposition: form-data; name=\"to\"\r\n\r\n");
                    sb.AppendFormat("{0}\r\n", to);
                    sb.AppendFormat("--{0}\r\n", boundary);
                    sb.Append("Content-Disposition: form-data; name=\"from\"\r\n\r\n");
                    sb.AppendFormat("{0}\r\n", this.phoneNumber);
                    sb.AppendFormat("--{0}\r\n", boundary);
                    sb.AppendFormat("Content-Disposition: form-data; name=\"file\"; filename=\"{0}\"\r\n", hashname);
                    sb.AppendFormat("Content-Type: {0}\r\n\r\n", contenttype);
                    string header = sb.ToString();

                    sb = new StringBuilder();
                    sb.AppendFormat("\r\n--{0}--\r\n", boundary);
                    string footer = sb.ToString();

                    long clength = size + header.Length + footer.Length;

                    sb = new StringBuilder();
                    sb.AppendFormat("POST {0}\r\n", uploadUrl);
                    sb.AppendFormat("Content-Type: multipart/form-data; boundary={0}\r\n", boundary);
                    sb.AppendFormat("Host: {0}\r\n", uri.Host);
                    sb.AppendFormat("User-Agent: {0}\r\n", WhatsConstants.UserAgent);
                    sb.AppendFormat("Content-Length: {0}\r\n\r\n", clength);
                    string post = sb.ToString();

                    TcpClient tc = new TcpClient(uri.Host, 443);
                    SslStream ssl = new SslStream(tc.GetStream());
                    try
                    {
                        ssl.AuthenticateAsClient(uri.Host);
                    }
                    catch (Exception e)
                    {
                        throw e;
                    }

                    List<byte> buf = new List<byte>();
                    buf.AddRange(Encoding.UTF8.GetBytes(post));
                    buf.AddRange(Encoding.UTF8.GetBytes(header));
                    buf.AddRange(fileData);
                    buf.AddRange(Encoding.UTF8.GetBytes(footer));

                    ssl.Write(buf.ToArray(), 0, buf.ToArray().Length);

                    //moment of truth...
                    buff = new byte[1024];
                    ssl.Read(buff, 0, 1024);

                    string result = Encoding.UTF8.GetString(buff);
                    foreach (string line in result.Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries))
//.........这里部分代码省略.........
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:101,代码来源:WhatsApp.cs


示例2: SendClientConfig

 public void SendClientConfig(string platform, string lg, string lc, Uri pushUri, bool preview, bool defaultSetting, bool groupsSetting, IEnumerable<GroupSetting> groups, Action onCompleted, Action<int> onError)
 {
     string id = TicketCounter.MakeId("config_");
     var node = new ProtocolTreeNode("iq",
                                 new[]
                                 {
                                     new KeyValue("id", id), new KeyValue("type", "set"),
                                     new KeyValue("to", "") //this.Login.Domain)
                                 },
                                 new ProtocolTreeNode[]
                                 {
                                     new ProtocolTreeNode("config",
                                     new[]
                                         {
                                             new KeyValue("xmlns","urn:xmpp:whatsapp:push"),
                                             new KeyValue("platform", platform),
                                             new KeyValue("lg", lg),
                                             new KeyValue("lc", lc),
                                             new KeyValue("clear", "0"),
                                             new KeyValue("id", pushUri.ToString()),
                                             new KeyValue("preview",preview ? "1" : "0"),
                                             new KeyValue("default",defaultSetting ? "1" : "0"),
                                             new KeyValue("groups",groupsSetting ? "1" : "0")
                                         },
                                     this.ProcessGroupSettings(groups))
                                 });
     this.SendNode(node);
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:28,代码来源:WhatsApp.cs


示例3: ParseMessageRecv

        /// <summary>
        /// Parse recieved message
        /// </summary>
        /// <param name="messageNode">TreeNode that contains the recieved message</param>
        public void ParseMessageRecv(ProtocolTreeNode messageNode)
        {
            FMessage.Builder builder = new FMessage.Builder();
            string tmpAttrbId = messageNode.GetAttribute("id");
            string tmpAttrFrom = messageNode.GetAttribute("from");
            string tmpAttrFromName = messageNode.GetAttribute("");
            string tmpAttrFromJid = messageNode.GetAttribute("author") ?? "";
            string tmpAttrType = messageNode.GetAttribute("type");
            string tmpTAttribT = messageNode.GetAttribute("t");

            long result = 0L;
            if (!string.IsNullOrEmpty(tmpTAttribT) && long.TryParse(tmpTAttribT, out result))
            {
                builder.Timestamp(new DateTime?(WhatsConstants.UnixEpoch.AddSeconds((double)result)));
            }

            if ("error".Equals(tmpAttrType))
            {
                TypeError(messageNode, tmpAttrbId, tmpAttrFrom);
            }
            else if ("subject".Equals(tmpAttrType))
            {
                TypeSubject(messageNode, tmpAttrFrom, tmpAttrFromJid, tmpAttrbId, tmpTAttribT);
            }
            else if ("chat".Equals(tmpAttrType))
            {
                TypeChat(messageNode, tmpAttrFrom, tmpAttrbId, builder, tmpAttrFromJid);
            }
            else if ("notification".Equals(tmpAttrType))
            {
                TypeNotification(messageNode, tmpAttrFrom, tmpAttrbId);
            }
        }
开发者ID:netoCastillo,项目名称:WhatsAPINet,代码行数:37,代码来源:MessageRecvResponse.cs


示例4: SendSync

 public void SendSync(string[] numbers, SyncMode mode = SyncMode.Delta, SyncContext context = SyncContext.Background, int index = 0, bool last = true)
 {
     List<ProtocolTreeNode> users = new List<ProtocolTreeNode>();
     foreach (string number in numbers)
     {
         string _number = number;
         if (!_number.StartsWith("+", StringComparison.InvariantCulture))
             _number = string.Format("+{0}", number);
         users.Add(new ProtocolTreeNode("user", null, System.Text.Encoding.UTF8.GetBytes(_number)));
     }
     ProtocolTreeNode node = new ProtocolTreeNode("iq", new KeyValue[]
     {
         new KeyValue("to", GetJID(this.phoneNumber)),
         new KeyValue("type", "get"),
         new KeyValue("id", TicketCounter.MakeId("sendsync_")),
         new KeyValue("xmlns", "urn:xmpp:whatsapp:sync")
     }, new ProtocolTreeNode("sync", new KeyValue[]
         {
             new KeyValue("mode", mode.ToString().ToLowerInvariant()),
             new KeyValue("context", context.ToString().ToLowerInvariant()),
             new KeyValue("sid", DateTime.Now.ToFileTimeUtc().ToString()),
             new KeyValue("index", index.ToString()),
             new KeyValue("last", last.ToString())
         },
         users.ToArray()
         )
     );
     this.SendNode(node);
 }
开发者ID:bastidererste,项目名称:WhatsAPINet,代码行数:29,代码来源:WhatsApp.cs


示例5: WappMessage

 public WappMessage(ProtocolTreeNode node, string jid)
 {
     ProtocolTreeNode body = node.GetChild("body");
     ProtocolTreeNode media = node.GetChild("media");
     if (node.tag == "message")
     {
         if (node.GetAttribute("type") == "subject")
         {
             Contact c = ContactStore.GetContactByJid(node.GetAttribute("author"));
             this.data = c.ToString() + " changed subject to \"" + Encoding.ASCII.GetString(node.GetChild("body").GetData()) + "\"";
         }
         else
         {
             if (body != null)
             {
                 this.data = Encoding.ASCII.GetString(node.GetChild("body").GetData());
                 this.type = "text";
             }
             else if (media != null)
             {
                 this.type = media.GetAttribute("type");
                 if (media.data != null && media.data.Length > 0)
                 {
                     this.preview = Convert.ToBase64String(media.data);
                 }
                 this.data = media.GetAttribute("url");
             }
         }
         this.from_me = false;
         this.timestamp = DateTime.UtcNow;
         this.jid = jid;
     }
 }
开发者ID:JeremyManz,项目名称:WinApp.NET,代码行数:33,代码来源:Message.cs


示例6: ProtocolTreeNode

 public ProtocolTreeNode(string tag, IEnumerable<KeyValue> attributeHash, ProtocolTreeNode children = null)
 {
     this.tag = tag ?? "";
     this.attributeHash = attributeHash ?? new KeyValue[0];
     this.children = children != null ? new ProtocolTreeNode[] { children } : new ProtocolTreeNode[0];
     this.data = new byte[0];
 }
开发者ID:krish-kapadia,项目名称:WhatsAPINet,代码行数:7,代码来源:ProtocolTreeNode.cs


示例7: AddMessage

 public void AddMessage(ProtocolTreeNode node)
 {
     lock (messageLock)
     {
         this.messageQueue.Add(node);
     }
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:7,代码来源:WhatsAppBase.cs


示例8: fireOnGetMessageAudio

 protected void fireOnGetMessageAudio(ProtocolTreeNode mediaNode, string from, string id, string fileName, int fileSize, string url, byte[] preview, string name)
 {
     if (this.OnGetMessageAudio != null)
     {
         this.OnGetMessageAudio(mediaNode, from, id, fileName, fileSize, url, preview, name);
     }
 }
开发者ID:kunalsmehtajobs,项目名称:Chat-API-NET,代码行数:7,代码来源:WhatsEventBase.cs


示例9: fireOnGetMessage

 protected void fireOnGetMessage(ProtocolTreeNode messageNode, string from, string id, string name, string message, bool receipt_sent)
 {
     if (this.OnGetMessage != null)
     {
         this.OnGetMessage(messageNode, from, id, name, message, receipt_sent);
     }
 }
开发者ID:kunalsmehtajobs,项目名称:Chat-API-NET,代码行数:7,代码来源:WhatsEventBase.cs


示例10: WaUploadResponse

 public WaUploadResponse(ProtocolTreeNode node)
 {
     node = node.GetChild("duplicate");
     if (node != null)
     {
         int oSize, oWidth, oHeight, oDuration, oAsampfreq, oAbitrate;
         this.url = node.GetAttribute("url");
         this.mimetype = node.GetAttribute("mimetype");
         Int32.TryParse(node.GetAttribute("size"), out oSize);
         this.filehash = node.GetAttribute("filehash");
         this.type = node.GetAttribute("type");
         Int32.TryParse(node.GetAttribute("width"), out oWidth);
         Int32.TryParse(node.GetAttribute("height"), out oHeight);
         Int32.TryParse(node.GetAttribute("duration"), out oDuration);
         this.acodec = node.GetAttribute("acodec");
         Int32.TryParse(node.GetAttribute("asampfreq"), out oAsampfreq);
         this.asampfmt = node.GetAttribute("asampfmt");
         Int32.TryParse(node.GetAttribute("abitrate"), out oAbitrate);
         this.size = oSize;
         this.width = oWidth;
         this.height = oHeight;
         this.duration = oDuration;
         this.asampfreq = oAsampfreq;
         this.abitrate = oAbitrate;
     }
 }
开发者ID:4nh51rk,项目名称:WhatsAPINet,代码行数:26,代码来源:WaUploadResponse.cs


示例11: addFeatures

        protected ProtocolTreeNode addFeatures()
        {
			ProtocolTreeNode readReceipts = new ProtocolTreeNode ("readreceipts", null,null, null);
			ProtocolTreeNode groups_v2 = new ProtocolTreeNode ("groups_v2", null,null, null);
			ProtocolTreeNode privacy = new ProtocolTreeNode ("privacy", null,null, null);
			ProtocolTreeNode presencev2 = new ProtocolTreeNode ("presence", null,null, null);
			return new ProtocolTreeNode("stream:features", null, new ProtocolTreeNode[] {readReceipts, groups_v2, privacy, presencev2}, null);
        }
开发者ID:kunalsmehtajobs,项目名称:Chat-API-NET,代码行数:8,代码来源:WhatsSendBase.cs


示例12: Write

 public string Write(ProtocolTreeNode node)
 {
     if (node == null)
     {
         this.output += "\x00";
     }
     else
     {
         this.writeInternal(node);
     }
     return this.flushBuffer();
 }
开发者ID:rquiroz,项目名称:WhatsAPINet,代码行数:12,代码来源:BinTreeNodeWriter.cs


示例13: Write

 public byte[] Write(ProtocolTreeNode node, bool encrypt = true)
 {
     if (node == null)
     {
         this.buffer.Add(0);
     }
     else
     {
         this.DebugPrint(node.NodeString("SENT: "));
         this.writeInternal(node);
     }
     return this.flushBuffer(encrypt);
 }
开发者ID:hermanho,项目名称:WhatsAPINet,代码行数:13,代码来源:BinTreeNodeWriter.cs


示例14: SendClearDirty

 public void SendClearDirty(IEnumerable<string> categoryNames)
 {
     string id = TicketCounter.MakeId("clean_dirty_");
     //this.AddIqHandler(id, new FunXMPP.IqResultHandler(null));
     IEnumerable<ProtocolTreeNode> source = from category in categoryNames select new ProtocolTreeNode("category", new[] { new KeyValue("name", category) });
     var child = new ProtocolTreeNode("clean", new[] { new KeyValue("xmlns", "urn:xmpp:whatsapp:dirty") }, source);
     var node = new ProtocolTreeNode("iq",
                                     new[]
                                         {
                                             new KeyValue("id", id), new KeyValue("type", "set"),
                                             new KeyValue("to", "s.whatsapp.net")
                                         }, child);
     this.whatsNetwork.SendNode(node);
 }
开发者ID:rquiroz,项目名称:WhatsAPINet,代码行数:14,代码来源:WhatsSendHandler.cs


示例15: Write

 public byte[] Write(ProtocolTreeNode node, bool encrypt = true)
 {
     if (node == null)
     {
         this.buffer.Add(0);
     }
     else
     {
         if (WhatsApp.DEBUG && WhatsApp.DEBUGOutBound)
             this.DebugPrint(node.NodeString("tx "));
         this.writeInternal(node);
     }
     return this.flushBuffer(encrypt);
 }
开发者ID:elloko75,项目名称:Chat-API-NET,代码行数:14,代码来源:BinTreeNodeWriter.cs


示例16: TypeNotificationPicture

 /// <summary>
 /// Notify typing picture
 /// </summary>
 /// <param name="tmpChild">Child</param>
 /// <param name="tmpFrom">From?</param>
 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)
             {
                 WhatsEventHandler.OnPhotoChangedEventHandler(tmpFrom, item.GetAttribute("author"), photoId);
             }
         }
         else if (ProtocolTreeNode.TagEquals(item, "delete"))
         {
             WhatsEventHandler.OnPhotoChangedEventHandler(tmpFrom, item.GetAttribute("author"), null);
         }
     }
 }
开发者ID:netoCastillo,项目名称:WhatsAPINet,代码行数:23,代码来源:MessageRecvResponse.cs


示例17: WappMessage

 public WappMessage(ProtocolTreeNode node, string jid)
 {
     if (node.tag == "message")
     {
         if (node.GetAttribute("type") == "subject")
         {
             Contact c = ContactStore.GetContactByJid(node.GetAttribute("author"));
             this.data = c.ToString() + " changed subject to \"" + Encoding.ASCII.GetString(node.GetChild("body").GetData()) + "\"";
         }
         else
         {
             this.data = Encoding.ASCII.GetString(node.GetChild("body").GetData());
         }
         this.from_me = false;
         this.timestamp = DateTime.UtcNow;
         this.jid = jid;
     }
 }
开发者ID:GarethWright,项目名称:WinApp.NET,代码行数:18,代码来源:Message.cs


示例18: SendCreateGroupChat

 public void SendCreateGroupChat(string subject)
 {
     string id = TicketCounter.MakeId("create_group_");
     var child = new ProtocolTreeNode("group", new[] { new KeyValue("action", "create"), new KeyValue("subject", subject) });
     var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "w:g"), new KeyValue("to", "g.us") }, new ProtocolTreeNode[] { child });
     this.SendNode(node);
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:7,代码来源:WhatsApp.cs


示例19: SendVerbParticipants

 protected void SendVerbParticipants(string gjid, IEnumerable<string> participants, string id, string inner_tag)
 {
     IEnumerable<ProtocolTreeNode> source = from jid in participants select new ProtocolTreeNode("participant", new[] { new KeyValue("jid", jid) });
     var child = new ProtocolTreeNode(inner_tag, null, source);
     var node = new ProtocolTreeNode("iq", new[] { new KeyValue("id", id), new KeyValue("type", "set"), new KeyValue("xmlns", "w:g"), new KeyValue("to", GetJID(gjid)) }, child);
     this.SendNode(node);
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:7,代码来源:WhatsApp.cs


示例20: SendClose

 public void SendClose()
 {
     var node = new ProtocolTreeNode("presence", new[] { new KeyValue("type", "unavailable") });
     this.SendNode(node);
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:5,代码来源:WhatsApp.cs



注:本文中的WhatsAppApi.Helper.ProtocolTreeNode类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Parser.FMessage类代码示例发布时间:2022-05-26
下一篇:
C# Data.SqlDataAccess类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap