/// <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); }
/// <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"); }
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); }