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


C# Parser.FMessage类代码示例

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


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

示例1: WhatsEventHandlerOnMessageRecievedEvent

        private void WhatsEventHandlerOnMessageRecievedEvent(FMessage mess)
        {
            if (mess == null || mess.key.remote_jid == null || mess.key.remote_jid.Length == 0)
                return;

            if(!this.messageHistory.ContainsKey(mess.key.remote_jid))
                this.messageHistory.Add(mess.key.remote_jid, new List<FMessage>());

            this.messageHistory[mess.key.remote_jid].Add(mess);
            this.CheckIfUserRegisteredAndCreate(mess);
        }
开发者ID:rquiroz,项目名称:WhatsAPINet,代码行数:11,代码来源:WhatsMessageHandler.cs

示例2: CheckIfUserRegisteredAndCreate

        private void CheckIfUserRegisteredAndCreate(FMessage mess)
        {
            if (this.messageHistory.ContainsKey(mess.key.remote_jid))
                return;

            var jidSplit = mess.key.remote_jid.Split('@');
            WhatsUser tmpWhatsUser = new WhatsUser(jidSplit[0], jidSplit[1], mess.key.serverNickname);
            User tmpUser = new User(jidSplit[0], jidSplit[1]);
            tmpUser.SetUser(tmpWhatsUser);

            this.messageHistory.Add(mess.key.remote_jid, new List<FMessage>());
            this.messageHistory[mess.key.remote_jid].Add(mess);
        }
开发者ID:rquiroz,项目名称:WhatsAPINet,代码行数:13,代码来源:WhatsMessageHandler.cs

示例3: OnMessageRecievedEventHandler

        /*
         * No need to add documentation here
         * User will only handle the delagates and events
         * */

        internal static void OnMessageRecievedEventHandler(FMessage mess)
        {
            var h = MessageRecievedEvent;
            if (h == null)
                return;
            foreach (var tmpSingleCast in h.GetInvocationList())
            {
                var tmpSyncInvoke = tmpSingleCast.Target as ISynchronizeInvoke;
                if (tmpSyncInvoke != null && tmpSyncInvoke.InvokeRequired)
                {
                    tmpSyncInvoke.BeginInvoke(tmpSingleCast, new object[] {mess});
                    continue;
                }
                h.BeginInvoke(mess, null, null);
            }
        }
开发者ID:Chandu-cuddle,项目名称:Chat-API-NET,代码行数:21,代码来源:WhatsEventHandler.cs

示例4: SendMessageWithBody

 protected void SendMessageWithBody(FMessage message, bool hidden = false)
 {
     var child = new ProtocolTreeNode("body", null, null, WhatsApp.SYSEncoding.GetBytes(message.data));
     this.SendNode(GetMessageNode(message, child, hidden));
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:5,代码来源:WhatsApp.cs

示例5: getFmessageImage

        protected FMessage getFmessageImage(string to, byte[] ImageData, ImageType imgtype)
        {
            string type = string.Empty;
            string extension = string.Empty;
            switch (imgtype)
            {
                case ImageType.PNG:
                    type = "image/png";
                    extension = "png";
                    break;
                case ImageType.GIF:
                    type = "image/gif";
                    extension = "gif";
                    break;
                default:
                    type = "image/jpeg";
                    extension = "jpg";
                    break;
            }

            //create hash
            string filehash = string.Empty;
            using(HashAlgorithm sha = HashAlgorithm.Create("sha256"))
            {
                byte[] raw = sha.ComputeHash(ImageData);
                filehash = Convert.ToBase64String(raw);
            }

            //request upload
            WaUploadResponse response = this.UploadFile(filehash, "image", ImageData.Length, ImageData, to, type, extension);

            if (response != null && !String.IsNullOrEmpty(response.url))
            {
                //send message
                FMessage msg = new FMessage(to, true)
                {
                    media_wa_type = FMessage.Type.Image,
                    media_mime_type = response.mimetype,
                    media_name = response.url.Split('/').Last(),
                    media_size = response.size,
                    media_url = response.url,
                    binary_data = this.CreateThumbnail(ImageData)
                };
                return msg;
            }
            return null;
        }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:47,代码来源:WhatsApp.cs

示例6: GetMessageNode

 protected static ProtocolTreeNode GetMessageNode(FMessage message, ProtocolTreeNode pNode, bool hidden = false)
 {
     return new ProtocolTreeNode("message", new[] {
         new KeyValue("to", message.identifier_key.remote_jid),
         new KeyValue("type", message.media_wa_type == FMessage.Type.Undefined?"text":"media"),
         new KeyValue("id", message.identifier_key.id)
     },
     new ProtocolTreeNode[] {
         new ProtocolTreeNode("x", new KeyValue[] { new KeyValue("xmlns", "jabber:x:event") }, new ProtocolTreeNode("server", null)),
         pNode,
         new ProtocolTreeNode("offline", null)
     });
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:13,代码来源:WhatsApp.cs

示例7: SendMessageVcard

 public void SendMessageVcard(string to, string name, string vcard_data)
 {
     var tmpMessage = new FMessage(GetJID(to), true) { data = vcard_data, media_wa_type = FMessage.Type.Contact, media_name = name };
     this.SendMessage(tmpMessage, this.hidden);
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:5,代码来源:WhatsApp.cs

示例8: SendMessage

 public void SendMessage(FMessage message, bool hidden = false)
 {
     if (message.media_wa_type != FMessage.Type.Undefined)
     {
         this.SendMessageWithMedia(message);
     }
     else
     {
         this.SendMessageWithBody(message, hidden);
     }
 }
开发者ID:RCOliveira,项目名称:WhatsAPINet,代码行数:11,代码来源:WhatsApp.cs

示例9: SendMessageReceived

        protected void SendMessageReceived(FMessage message, string response)
        {
            ProtocolTreeNode node = new ProtocolTreeNode("receipt", new[] {
                new KeyValue("to", message.identifier_key.remote_jid),
                new KeyValue("id", message.identifier_key.id)
            });

            this.SendNode(node);
        }
开发者ID:badr19,项目名称:WhatsAPINet,代码行数:9,代码来源:WhatsSendBase.cs

示例10: WhatsEventHandlerOnMessageRecievedEvent

 private void WhatsEventHandlerOnMessageRecievedEvent(FMessage mess)
 {
     var tmpMes = mess.data;
     this.AddNewText(this.user.UserName, tmpMes);
 }
开发者ID:richchen1010,项目名称:WhatsAPINet,代码行数:5,代码来源:frmUserChat.cs

示例11: GetMessageNode

 /// <summary>
 /// Get the message node
 /// </summary>
 /// <param name="message">the message</param>
 /// <param name="pNode">The protocol tree node</param>
 /// <returns>An instance of the ProtocolTreeNode class.</returns>
 internal static ProtocolTreeNode GetMessageNode(FMessage message, ProtocolTreeNode pNode, bool hidden = false)
 {
     return new ProtocolTreeNode("message", new[] {
         new KeyValue("to", message.identifier_key.remote_jid),
         new KeyValue("type", "chat"),
         new KeyValue("id", message.identifier_key.id)
     },
     new ProtocolTreeNode[] {
         new ProtocolTreeNode("x", new KeyValue[] { new KeyValue("xmlns", "jabber:x:event") }, new ProtocolTreeNode("server", null)),
         pNode,
         new ProtocolTreeNode("offline", null)
     });
 }
开发者ID:GruppoPotente,项目名称:WhatsAPINet,代码行数:19,代码来源:WhatsSendHandler.cs

示例12: SendMessageReceived

 /// <summary>
 /// Tell the server the message has been recieved.
 /// </summary>
 /// <param name="message">An instance of the FMessage class.</param>
 public void SendMessageReceived(FMessage message, string response)
 {
     var child = new ProtocolTreeNode(response, new[] { new KeyValue("xmlns", "urn:xmpp:receipts") });
     var node = new ProtocolTreeNode("message", new[] { new KeyValue("to", message.identifier_key.remote_jid), new KeyValue("type", "chat"), new KeyValue("id", message.identifier_key.id) }, child);
     this.whatsNetwork.SendData(this._binWriter.Write(node));
 }
开发者ID:GruppoPotente,项目名称:WhatsAPINet,代码行数:10,代码来源:WhatsSendHandler.cs

示例13: SendMessageReceived

        protected void SendMessageReceived(FMessage message, string type = "read")
        {
            KeyValue toAttrib = new KeyValue("to", message.identifier_key.remote_jid);
            KeyValue idAttrib = new KeyValue("id", message.identifier_key.id);

            var attribs = new List<KeyValue>();
            attribs.Add(toAttrib);
            attribs.Add(idAttrib);
            if (type.Equals("read"))
            {
                KeyValue typeAttrib = new KeyValue("type", type);
                attribs.Add(typeAttrib);
            }

            ProtocolTreeNode node = new ProtocolTreeNode("receipt", attribs.ToArray());

            this.SendNode(node);
        }
开发者ID:jwerba,项目名称:WhatsAPINet,代码行数:18,代码来源:WhatsSendBase.cs

示例14: MessageImage

        /// <summary>
        /// Send an image to a person
        /// </summary>
        /// <param name="msgid">The id of the message</param>
        /// <param name="to">the reciepient</param>
        /// <param name="url">The url to the image</param>
        /// <param name="file">Filename</param>
        /// <param name="size">The size of the image in string format</param>
        /// <param name="icon">Icon</param>
        public void MessageImage(string to, string filepath)
        {
            to = this.GetJID(to);
            FileInfo finfo = new FileInfo(filepath);
            string type = string.Empty;
            switch (finfo.Extension)
            {
                case ".png":
                    type = "image/png";
                    break;
                case ".gif":
                    type = "image/gif";
                    break;
                default:
                    type = "image/jpeg";
                    break;
            }

            //create hash
            string filehash = string.Empty;
            using(FileStream fs = File.OpenRead(filepath))
            {
                using(BufferedStream bs = new BufferedStream(fs))
                {
                    using(HashAlgorithm sha = HashAlgorithm.Create("sha256"))
                    {
                        byte[] raw = sha.ComputeHash(bs);
                        filehash = Convert.ToBase64String(raw);
                    }
                }
            }

            //request upload
            UploadResponse response = this.UploadFile(filehash, "image", finfo.Length, filepath, to, type);

            if (response != null && !String.IsNullOrEmpty(response.url))
            {
                //send message
                FMessage msg = new FMessage(to, true) { identifier_key = { id = TicketManager.GenerateId() }, media_wa_type = FMessage.Type.Image, media_mime_type = response.mimetype, media_name = response.url.Split('/').Last(), media_size = response.size, media_url = response.url, binary_data = this.CreateThumbnail(filepath) };
                this.WhatsSendHandler.SendMessage(msg);
            }
        }
开发者ID:jergasmx,项目名称:WhatsAPINet,代码行数:51,代码来源:WhatsApp.cs

示例15: Message

 /// <summary>
 /// Send a message to a person
 /// </summary>
 /// <param name="to">The phone number to send</param>
 /// <param name="txt">The text that needs to be send</param>
 public void Message(string to, string txt)
 {
     var tmpMessage = new FMessage(this.GetJID(to), true) { identifier_key = { id = TicketManager.GenerateId() }, data = txt };
     this.WhatsParser.WhatsSendHandler.SendMessage(tmpMessage);
 }
开发者ID:jergasmx,项目名称:WhatsAPINet,代码行数:10,代码来源:WhatsApp.cs


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