public void PlaceCall(string destination, SDP sdp) { m_destination = destination; m_sdp = sdp; XElement descriptionElement = SDPToJingle.GetDescription(m_sdp); m_descriptionID = Crypto.GetRandomString(6); XElement callElement = new XElement(JabberClientNS + "iq", new XAttribute("from", m_jid), new XAttribute("id", m_descriptionID), new XAttribute("to", m_destination), new XAttribute("type", "set"), new XElement(m_sessionNS + "session", new XAttribute("type", "initiate"), new XAttribute("id", m_sessionID), new XAttribute("initiator", m_jid), descriptionElement //new XElement(m_transportNS + "transport") )); logger.Debug("XMPPPhoneSession sending iq with session description."); m_xmppStream.WriteElement(callElement, OnIQResponse); }
/// <summary> /// Handler method for receiving iq requests from the remote server. /// </summary> /// <param name="iq">The iq stanza request received.</param> public void OnIQRequest(XElement iq) { logger.Debug("XMPPPhoneSession iq request, type=" + iq.Attribute("type").Value + "."); if (iq.Element(m_sessionNS + "session") != null) { XAttribute sessionType = iq.Element(m_sessionNS + "session").Attribute("type"); if (sessionType != null) { if (sessionType.Value == "candidates") { logger.Debug("XMPPPhoneSession session candidates stanza was received."); XElement candidate = (from cand in iq.Descendants(m_sessionNS + "session").Descendants(m_sessionNS + "candidate") where cand.Attribute("protocol").Value == "udp" select cand).First(); m_remoteIPAddress = candidate.Attribute("address").Value; Int32.TryParse(candidate.Attribute("port").Value, out m_remotePort); m_remoteUsername = candidate.Attribute("username").Value; m_remotePassword = candidate.Attribute("password").Value; } else if (sessionType.Value == "accept") { logger.Debug("XMPPPhoneSession session accept stanza was received."); m_payloads = (from pl in iq.Descendants(m_sessionNS + "session").Descendants(m_phoneNS + "description") .Descendants(m_phoneNS + "payload-type") select pl).ToList(); Accepted(SDPToJingle.GetSDP(m_remoteIPAddress, m_remotePort, m_remoteUsername, m_remotePassword, m_payloads)); } else if (sessionType.Value == "terminate") { logger.Debug("XMPPPhoneSession session terminate stanza was received."); Hungup(); } } else { logger.Warn("XMPPPhoneSession session element was received with a missing type attribute."); logger.Warn(iq.ToString()); } } else { logger.Warn("XMPPPhoneSession an iq element was received with no session element."); logger.Warn(iq.ToString()); } }
public void RetargetCallMedia(string ipAddress, int port) { XElement candidateElement = SDPToJingle.GetCandidate(ipAddress, port); string candidateIqID = Crypto.GetRandomString(6); XElement candElement = new XElement(JabberClientNS + "iq", new XAttribute("from", m_jid), new XAttribute("id", candidateIqID), new XAttribute("to", m_destination), new XAttribute("type", "set"), new XElement(m_sessionNS + "session", new XAttribute("type", "candidates"), new XAttribute("id", m_sessionID), new XAttribute("initiator", m_jid), candidateElement)); m_xmppStream.WriteElement(candElement, OnIQResponse); }
private void SendCandidates() { XElement candidatesElement = SDPToJingle.GetCandidates(m_sdp); string candidateIqID = Crypto.GetRandomString(6); XElement candElement = new XElement(JabberClientNS + "iq", new XAttribute("from", m_jid), new XAttribute("id", candidateIqID), new XAttribute("to", m_destination), new XAttribute("type", "set"), new XElement(m_sessionNS + "session", new XAttribute("type", "candidates"), new XAttribute("id", m_sessionID), new XAttribute("initiator", m_jid), candidatesElement)); logger.Debug("XMPPPhoneSession sending iq with session candidate."); m_xmppStream.WriteElement(candElement, OnIQResponse); }