예제 #1
0
        /// <summary>
        //// Build a XmppXElement from a Xml string.
        /// </summary>
        /// <param name="xml">The Xml string.</param>
        /// <param name="removeWhitespace">if set to <c>true</c> whitespaces will be removed on parsing.</param>
        /// <returns></returns>
        public static XmppXElement LoadXml(string xml, bool removeWhitespace)
        {
            XmppXElement stanza = null;
            var          sp     = new StreamParser();

            sp.OnStreamStart   += (el) => stanza = el;
            sp.OnStreamElement += (el) => stanza.Add(el);
            sp.OnStreamError   += (ex) => { throw ex; };

            var bytes = System.Text.Encoding.UTF8.GetBytes(xml);

            sp.Write(bytes, 0, bytes.Length);

            return(stanza);
        }
예제 #2
0
파일: Xmpp.cs 프로젝트: filiperamon/Beet
        /// <summary>
        /// Disconnect VOIP/Video/Audio call.
        /// </summary>
        /// <param name="to">recipient jid</param>
        public void SendSessionTerminate(string to)
        {
            Matrix.Xmpp.Jingle.Jingle jIq = new Matrix.Xmpp.Jingle.Jingle();

            jIq.Action = Matrix.Xmpp.Jingle.Action.SessionTerminate;
            jIq.GenerateSid();
            string defaultNs = "urn:xmpp:jingle:1";

            Matrix.Xml.XmppXElement eX = new Matrix.Xml.XmppXElement(defaultNs, "reason");
            eX.Add(new Matrix.Xml.XmppXElement(defaultNs, "success"));
            jIq.Add(eX);

            Iq denyIq = new Iq();

            denyIq.To   = to;
            denyIq.From = this._jid;
            denyIq.Type = Matrix.Xmpp.IqType.Set;
            denyIq.Add(jIq);

            xmppClient.Send(denyIq);
            Log.Info(">session-terminate");
        }
예제 #3
0
        public void SendSessionTerminate(string to, string sid)
        {
            Matrix.Xmpp.Jingle.Jingle jIq = new Matrix.Xmpp.Jingle.Jingle();

            jIq.Action = Matrix.Xmpp.Jingle.Action.SessionTerminate;
            jIq.Sid    = sid;
            string defaultNs = "urn:xmpp:jingle:1";

            Matrix.Xml.XmppXElement eX = new Matrix.Xml.XmppXElement(defaultNs, "reason");
            eX.Add(new Matrix.Xml.XmppXElement(defaultNs, "success"));
            jIq.Add(eX);

            Iq denyIq = new Iq();

            denyIq.To   = to;
            denyIq.From = this.jid;
            denyIq.Type = Matrix.Xmpp.IqType.Set;
            denyIq.Add(jIq);

            Console.Write(denyIq.ToString());
            xmppClient.Send(denyIq);
        }