Esempio n. 1
0
        /// <summary>Transmit RTT elements if needed.</summary>
        private bool JabberSendRTT()
        {
            bool rttSent = false;

            try
            {
                if (!rttEnabled)
                {
                    return(false);
                }

                if (!encoderRTT.IsEmpty)
                {
                    // Create the XMPP <message> with <rtt> updates, and transmit.
                    jabber.protocol.client.Message reply = new jabber.protocol.client.Message(_jabberClient.Document);
                    reply.To = JID.Bare;
                    reply.AppendChild(encoderRTT.GetEncodedRTT());
                    if (enableChatStates)
                    {
                        reply.AppendChild(reply.OwnerDocument.CreateElement("composing")); //, "http://jabber.org/protocol/chatstates"));
                    }
                    _jabberClient.Write(reply);
                    rttSent = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("!!! Exception in JabberSendMessage(): " + ex.ToString());
            }
            return(rttSent);
        }
Esempio n. 2
0
        /// <summary>Transmit a message. Either a regular message, or real time text update, or both.</summary>
        private void JabberSendMessage(string body)
        {
            try
            {
                if (body == null)
                {
                    return;
                }

                // Create the XMPP <message>
                jabber.protocol.client.Message reply = new jabber.protocol.client.Message(_jabberClient.Document);
                reply.To = JID.Bare;

                // Add <rtt> element if needed (flush final RTT element with full message delivery)
                if (rttEnabled)
                {
                    encoderRTT.Encode(SendBox.Text, SendBox.SelectionStart);
                    if (!encoderRTT.IsEmpty)
                    {
                        reply.AppendChild(encoderRTT.GetEncodedRTT());
                    }
                    encoderRTT.NextMsg();
                }

                // Add the <body> element
                reply.Body = body;
                if (enableChatStates)
                {
                    reply.AppendChild(reply.OwnerDocument.CreateElement("active")); //, "http://jabber.org/protocol/chatstates"));
                }
                _jabberClient.Write(reply);
            }
            catch (Exception ex)
            {
                Console.WriteLine("!!! Exception in JabberSendMessage(): " + ex.ToString());
            }
        }
Esempio n. 3
0
        public override void Send(XmlElement contentElement)
        {
            Message message = new Message(base.Account.Client.Document);
            message.Type = MessageType.groupchat;
            message.To = m_Room.JID;

            message.AppendChild(contentElement);

            var activeElem = base.Account.Client.Document.CreateElement("active");
            activeElem.SetAttribute("xmlns", "http://jabber.org/protocol/chatstates");
            message.AppendChild(activeElem);

            base.Account.Client.Write(message);
            //base.AppendMessage(false, message);
        }
Esempio n. 4
0
        public override void Send(string html)
        {
            if (!String.IsNullOrEmpty(html)) {
                Message message = new Message(base.Account.Client.Document);
                message.Type = MessageType.groupchat;
                message.To = m_Room.JID;
                message.Html = html;

                var activeElem = base.Account.Client.Document.CreateElement("active");
                activeElem.SetAttribute("xmlns", "http://jabber.org/protocol/chatstates");
                message.AppendChild(activeElem);

                base.Account.Client.Write(message);
                //base.AppendMessage(false, message);
            }
        }
Esempio n. 5
0
        public override void Send(string html)
        {
            if (!String.IsNullOrEmpty(html)) {
                Message message = new Message(base.Account.Client.Document);
                message.Type = MessageType.chat;
                if (IsMucMessage)
                    message.To = this.Jid;
                else
                    message.To = new JID(m_Jid.User, m_Jid.Server, Resource);
                message.Html = html;

                var activeElem = base.Account.Client.Document.CreateElement("active");
                activeElem.SetAttribute("xmlns", "http://jabber.org/protocol/chatstates");
                message.AppendChild(activeElem);

                // FIXME: For some reason this blocks on large messages.
                base.Account.Client.Write(message);

                base.AppendMessage(false, message);
            }
        }
Esempio n. 6
0
        /// <summary>Transmit a message. Either a regular message, or real time text update, or both.</summary>
        private void JabberSendMessage(string body)
        {
            try
            {
                if (body == null) return;

                // Create the XMPP <message>
                jabber.protocol.client.Message reply = new jabber.protocol.client.Message(_jabberClient.Document);
                reply.To = JID.Bare;
                
                // Add <rtt> element if needed (flush final RTT element with full message delivery)
                if (rttEnabled)
                {
                    encoderRTT.Encode(SendBox.Text, SendBox.SelectionStart);
                    if (!encoderRTT.IsEmpty) reply.AppendChild(encoderRTT.GetEncodedRTT());
                    encoderRTT.NextMsg();
                }

                // Add the <body> element
                reply.Body = body;
                if (enableChatStates)
                {
                    reply.AppendChild(reply.OwnerDocument.CreateElement("active")); //, "http://jabber.org/protocol/chatstates"));
                }
                _jabberClient.Write(reply);
            }
            catch (Exception ex)
            {
                Console.WriteLine("!!! Exception in JabberSendMessage(): " + ex.ToString());
            }
        }
Esempio n. 7
0
        /// <summary>Transmit RTT elements if needed.</summary>
        private bool JabberSendRTT()
        {
            bool rttSent = false;
            try
            {
                if (!rttEnabled) return false;

                if (!encoderRTT.IsEmpty)
                {
                    // Create the XMPP <message> with <rtt> updates, and transmit.
                    jabber.protocol.client.Message reply = new jabber.protocol.client.Message(_jabberClient.Document);
                    reply.To = JID.Bare;
                    reply.AppendChild(encoderRTT.GetEncodedRTT());
                    if (enableChatStates)
                    {
                        reply.AppendChild(reply.OwnerDocument.CreateElement("composing")); //, "http://jabber.org/protocol/chatstates"));
                    }
                    _jabberClient.Write(reply);
                    rttSent = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("!!! Exception in JabberSendMessage(): " + ex.ToString());
            }
            return rttSent;
        }