當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。