当前位置: 首页>>代码示例>>C#>>正文


C# ProtocolTreeNode.NodeString方法代码示例

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


在下文中一共展示了ProtocolTreeNode.NodeString方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: handleMessage

        protected void handleMessage(ProtocolTreeNode node, bool autoReceipt)
        {
            if (!string.IsNullOrEmpty(node.GetAttribute("notify")))
            {
                string name = node.GetAttribute("notify");
                this.fireOnGetContactName(node.GetAttribute("from"), name);
            }
            if (node.GetAttribute("type") == "error")
            {
                throw new NotImplementedException(node.NodeString());
            }
            if (node.GetChild("body") != null)
            {
                //text message
                this.fireOnGetMessage(node, node.GetAttribute("from"), node.GetAttribute("id"), node.GetAttribute("notify"), System.Text.Encoding.UTF8.GetString(node.GetChild("body").GetData()), autoReceipt);
                if (autoReceipt)
                {
                    this.sendMessageReceived(node);
                }
            }
            if (node.GetChild("media") != null)
            {
                ProtocolTreeNode media = node.GetChild("media");
                //media message

                //define variables in switch
                string file, url, from, id;
                int size;
                byte[] preview, dat;
                id = node.GetAttribute("id");
                from = node.GetAttribute("from");
                switch (media.GetAttribute("type"))
                {
                    case "image":
                        url = media.GetAttribute("url");
                        file = media.GetAttribute("file");
                        size = Int32.Parse(media.GetAttribute("size"));
                        preview = media.GetData();
                        this.fireOnGetMessageImage(node, from, id, file, size, url, preview);
                        break;
                    case "audio":
                        file = media.GetAttribute("file");
                        size = Int32.Parse(media.GetAttribute("size"));
                        url = media.GetAttribute("url");
                        preview = media.GetData();
                        this.fireOnGetMessageAudio(node, from, id, file, size, url, preview);
                        break;
                    case "video":
                        file = media.GetAttribute("file");
                        size = Int32.Parse(media.GetAttribute("size"));
                        url = media.GetAttribute("url");
                        preview = media.GetData();
                        this.fireOnGetMessageVideo(node, from, id, file, size, url, preview);
                        break;
                    case "location":
                        double lon = double.Parse(media.GetAttribute("longitude"), System.Globalization.CultureInfo.InvariantCulture);
                        double lat = double.Parse(media.GetAttribute("latitude"), System.Globalization.CultureInfo.InvariantCulture);
                        preview = media.GetData();
                        name = media.GetAttribute("name");
                        url = media.GetAttribute("url");
                        this.fireOnGetMessageLocation(node, from, id, lon, lat, url, name, preview);
                        break;
                    case "vcard":
                        ProtocolTreeNode vcard = media.GetChild("vcard");
                        name = vcard.GetAttribute("name");
                        dat = vcard.GetData();
                        this.fireOnGetMessageVcard(node, from, id, name, dat);
                        break;
                }
                this.sendMessageReceived(node);
            }
        }
开发者ID:badr19,项目名称:WhatsAPINet,代码行数:72,代码来源:WhatsSendBase.cs

示例4: 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":
             //TODO
             break;
         case "contacts":
             //TODO
             break;
         default:
             throw new NotImplementedException(node.NodeString());
     }
     this.SendNotificationAck(node);
 }
开发者ID:richchen1010,项目名称:WhatsAPINet,代码行数:28,代码来源:WhatsSendBase.cs

示例5: wa_OnGetMessage

        public void wa_OnGetMessage(ProtocolTreeNode node, string from, string id, string name, string message, bool receipt_sent)
        {
            var pos = from.LastIndexOf('@');
            String fromuser;
            if (pos >= 0)
            {
                fromuser = from.Substring(0, pos);
            }
            else
            {
                fromuser = from;
            }
            if (from.Contains("g.us")){
                //Group message
                String JID = "";
                String Sender = node.NodeString();
                Sender = Sender.Substring(Sender.IndexOf("participant=") + 13);
                Sender = Sender.Substring(0, Sender.LastIndexOf("@"));
                int count = 0;
                string[] JIDCreator = fromuser.Split('-');
                foreach (string Idthing in JIDCreator)
                {
                    if (count == 1)
                    {
                        JID = Idthing;
                    }
                    count++;
                }
                if (Destphone.Text == JID)
                {
                    this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.AppendText("(" + Sender + "): " + message + Environment.NewLine); });
                    this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.Select(ChatLog.Text.Length, 0); });
                    this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.SelectionStart = ChatLog.Text.Length; });
                    this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.ScrollToCaret(); });
                }
                DateTime nx = new DateTime(1970, 1, 1); // UNIX epoch date
                TimeSpan ts = DateTime.UtcNow - nx; // UtcNow, because timestamp is in GMT
                SQLiteDatabase db = new SQLiteDatabase();
                Dictionary<String, String> data = new Dictionary<String, String>();
                data.Add("JID", JID);
                data.Add("SENDER", Sender);
                message = message.Replace("'", "''");
                data.Add("MESSAGE", message);
                data.Add("DATE", ((int)ts.TotalSeconds).ToString());
                try
                {
                    db.Insert("GROUPCHAT", data);
                }
                catch (Exception crap)
                {
                    MessageBox.Show(crap.Message);
                }
            }else{
                //Normal message
            if (Destphone.Text == fromuser)
            {
                this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.AppendText("(" + fromuser + "): " + message + Environment.NewLine); });
                this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.Select(ChatLog.Text.Length, 0); });
                this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.SelectionStart = ChatLog.Text.Length; });
                this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { ChatLog.ScrollToCaret(); });
            }
            DateTime nx = new DateTime(1970, 1, 1); // UNIX epoch date
            TimeSpan ts = DateTime.UtcNow - nx; // UtcNow, because timestamp is in GMT

            SQLiteDatabase db = new SQLiteDatabase();
            Dictionary<String, String> data = new Dictionary<String, String>();
            data.Add("ID", messageid.ToString());
            data.Add("USER", fromuser);
            data.Add("USERTO", "You");
            message = message.Replace("'", "''");
            data.Add("MESSAGE", message);
            data.Add("DATE", ((int)ts.TotalSeconds).ToString());
            messageid = messageid++;
            this.BeginInvoke((System.Windows.Forms.MethodInvoker)delegate() { messageid = messageid + 1; });
            try
            {
                db.Insert("MESSAGES", data);
            }
            catch (Exception crap)
            {
                MessageBox.Show(crap.Message);
            }
            }
        }
开发者ID:abazad,项目名称:Whatsapp4Windows,代码行数:84,代码来源:Form1.cs


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