/// <summary> /// TODO: Documentation SessionInfo /// </summary> /// <param name="to"></param> /// <param name="sid"></param> /// <param name="payload"></param> /// <returns></returns> public void SessionInfo(JID to, String sid, Element payload) { JingleIQ jingleIq; if (payload != null) { jingleIq = new JingleIQ(payload.OwnerDocument); } else { jingleIq = new JingleIQ(this.Stream.Document); } jingleIq.From = this.Stream.JID; jingleIq.To = to; jingleIq.Type = IQType.set; jingleIq.Instruction.Action = ActionType.session_info; jingleIq.Instruction.Sid = sid; if (payload != null) { jingleIq.Instruction.AddChild(payload); } this.Stream.Write(jingleIq); }
/// <summary> /// Constructs a Jingle IQ Paquet containing Jingle most common arguments /// </summary> /// <param name="to">Recipient of this Jingle IQ Paquet</param> /// <param name="action">Type of Action this request is about</param> /// <param name="sid"> /// SID of the session which can be created using JingleUtilities.GenerateSid for a session-initiate /// paquet construction or was given by a peer who initiated a session which had been accepted /// </param> /// <param name="contentName">The name of the content, only for informative purposes but mandatory</param> /// <param name="description">An XML element using root tag <description></description></param> /// <param name="transport">An XML element using root tag <transport></transport></param> /// <returns></returns> public JingleIQ SessionRequest(JID to, ActionType action, String sid, String contentName, Element description, Element transport) { JingleIQ jingleIq; if (description != null) { jingleIq = new JingleIQ(description.OwnerDocument); } else if (transport != null) { jingleIq = new JingleIQ(transport.OwnerDocument); } else { jingleIq = new JingleIQ(new XmlDocument()); } jingleIq.From = this.Stream.JID; jingleIq.To = to; jingleIq.Type = IQType.set; jingleIq.Instruction.Action = action; jingleIq.Instruction.Sid = sid; if (action == ActionType.session_initiate) { jingleIq.Instruction.Initiator = this.Stream.JID; } else if (action == ActionType.session_accept) { jingleIq.Instruction.Responder = this.Stream.JID; } if (!String.IsNullOrEmpty(contentName)) { JingleContent jcnt = jingleIq.Instruction.AddContent(contentName); if (description != null) { jcnt.AddChild(description); } if (transport != null) { jcnt.AddChild(transport); } } else { throw new InvalidOperationException("Content name cannot be null or an empty string"); } return(jingleIq); }
/// <summary> /// TODO: Documentation turnManager_OnAllocateSucceed /// </summary> /// <param name="sender"></param> /// <param name="allocation"></param> /// <param name="sentMsg"></param> /// <param name="receivedMsg"></param> private void turnManager_OnAllocateSucceed(object sender, TurnAllocation allocation, StunMessage sentMsg, StunMessage receivedMsg) { if (this.StartingSessionRecipient != null) { this.turnSessions[this.StartingSessionSid].TurnAllocation = allocation; XmlDocument doc = new XmlDocument(); // Jingle Transport JingleIce jingleIce = new JingleIce(doc) { Pwd = JingleUtilities.GenerateIcePwd, Ufrag = JingleUtilities.GenerateIceUfrag }; if (this.OnIceCandidatesGathering != null) { this.OnIceCandidatesGathering(this, jingleIce, (sender as TurnManager).HostEP, this.turnSessions[this.StartingSessionSid].UseTurnOnly, allocation); } this.localCandidates.Add(this.StartingSessionSid, jingleIce.GetCandidates()); JingleIQ jingleIq = null; // Jingle Description Element jingleDescription = null; String contentName = null; if (this.OnDescriptionGathering != null) { this.OnDescriptionGathering(this, doc, this.StartingSessionSid, ref jingleDescription, ref contentName); } jingleIq = this.JingleManager.SessionRequest(this.StartingSessionRecipient, this.StartingSessionAction, this.StartingSessionSid, contentName, jingleDescription, jingleIce); //this.jingleManager.FindSession(this.StartingSessionSid).Local = jingleIq.Instruction; this.Stream.Write(jingleIq); } }
/// <summary> /// TODO: Documentation jingleManager_OnReceivedSessionAccept /// </summary> /// <param name="sender"></param> /// <param name="iq"></param> private void jingleManager_OnReceivedSessionAccept(object sender, IQ iq) { Jingle jingle = iq.Query as Jingle; JingleIQ jingleIq = new JingleIQ(this.Stream.Document); jingleIq.From = this.Stream.JID; jingleIq.To = iq.From; jingleIq.Type = IQType.set; jingleIq.Instruction.Action = ActionType.transport_info; jingleIq.Instruction.Sid = jingle.Sid; JingleContent jcnt = jingleIq.Instruction.AddContent("checkConnectivity"); this.Stream.Write(jingleIq); this.CheckConnectivity(jingle.Sid); iq.Handled = true; }
/// <summary> /// TODO: Documentation SessionTerminate /// </summary> /// <param name="to"></param> /// <param name="sid"></param> /// <param name="reasonType"></param> /// <returns></returns> public void SessionTerminate(JID to, String sid, ReasonType?reasonType) { JingleIQ jingleIq = new JingleIQ(this.Stream.Document); jingleIq.From = this.Stream.JID; jingleIq.To = to; jingleIq.Type = IQType.set; jingleIq.Instruction.Action = ActionType.session_terminate; jingleIq.Instruction.Sid = sid; if (reasonType.HasValue) { JingleReason reason = new JingleReason(jingleIq.OwnerDocument); switch (reasonType) { case ReasonType.alternative_session: reason.Reason = new AlternativeSession(jingleIq.OwnerDocument); break; case ReasonType.busy: reason.Reason = new Busy(jingleIq.OwnerDocument); break; case ReasonType.cancel: reason.Reason = new Cancel(jingleIq.OwnerDocument); break; case ReasonType.connectivity_error: reason.Reason = new ConnectivityError(jingleIq.OwnerDocument); break; case ReasonType.decline: reason.Reason = new JingleDecline(jingleIq.OwnerDocument); break; case ReasonType.expired: reason.Reason = new Expired(jingleIq.OwnerDocument); break; case ReasonType.failed_application: reason.Reason = new FailedApplication(jingleIq.OwnerDocument); break; case ReasonType.failed_transport: reason.Reason = new FailedTransport(jingleIq.OwnerDocument); break; case ReasonType.general_error: reason.Reason = new GeneralError(jingleIq.OwnerDocument); break; case ReasonType.gone: reason.Reason = new Gone(jingleIq.OwnerDocument); break; case ReasonType.incompatible_parameters: reason.Reason = new IncompatibleParameters(jingleIq.OwnerDocument); break; case ReasonType.media_error: reason.Reason = new MediaError(jingleIq.OwnerDocument); break; case ReasonType.security_error: reason.Reason = new SecurityError(jingleIq.OwnerDocument); break; case ReasonType.success: reason.Reason = new Success(jingleIq.OwnerDocument); break; case ReasonType.timeout: reason.Reason = new Timeout(jingleIq.OwnerDocument); break; case ReasonType.unsupported_applications: reason.Reason = new UnsupportedApplications(jingleIq.OwnerDocument); break; case ReasonType.unsupported_transports: reason.Reason = new UnsupportedTransports(jingleIq.OwnerDocument); break; } jingleIq.Instruction.Reason = reason; } this.Stream.Write(jingleIq); }
/// <summary> /// TODO: Documentation SessionTerminate /// </summary> /// <param name="to"></param> /// <param name="sid"></param> /// <param name="reasonType"></param> /// <returns></returns> public void SessionTerminate(JID to, String sid, ReasonType? reasonType) { JingleIQ jingleIq = new JingleIQ(this.Stream.Document); jingleIq.From = this.Stream.JID; jingleIq.To = to; jingleIq.Type = IQType.set; jingleIq.Instruction.Action = ActionType.session_terminate; jingleIq.Instruction.Sid = sid; if (reasonType.HasValue) { JingleReason reason = new JingleReason(jingleIq.OwnerDocument); switch (reasonType) { case ReasonType.alternative_session: reason.Reason = new AlternativeSession(jingleIq.OwnerDocument); break; case ReasonType.busy: reason.Reason = new Busy(jingleIq.OwnerDocument); break; case ReasonType.cancel: reason.Reason = new Cancel(jingleIq.OwnerDocument); break; case ReasonType.connectivity_error: reason.Reason = new ConnectivityError(jingleIq.OwnerDocument); break; case ReasonType.decline: reason.Reason = new JingleDecline(jingleIq.OwnerDocument); break; case ReasonType.expired: reason.Reason = new Expired(jingleIq.OwnerDocument); break; case ReasonType.failed_application: reason.Reason = new FailedApplication(jingleIq.OwnerDocument); break; case ReasonType.failed_transport: reason.Reason = new FailedTransport(jingleIq.OwnerDocument); break; case ReasonType.general_error: reason.Reason = new GeneralError(jingleIq.OwnerDocument); break; case ReasonType.gone: reason.Reason = new Gone(jingleIq.OwnerDocument); break; case ReasonType.incompatible_parameters: reason.Reason = new IncompatibleParameters(jingleIq.OwnerDocument); break; case ReasonType.media_error: reason.Reason = new MediaError(jingleIq.OwnerDocument); break; case ReasonType.security_error: reason.Reason = new SecurityError(jingleIq.OwnerDocument); break; case ReasonType.success: reason.Reason = new Success(jingleIq.OwnerDocument); break; case ReasonType.timeout: reason.Reason = new Timeout(jingleIq.OwnerDocument); break; case ReasonType.unsupported_applications: reason.Reason = new UnsupportedApplications(jingleIq.OwnerDocument); break; case ReasonType.unsupported_transports: reason.Reason = new UnsupportedTransports(jingleIq.OwnerDocument); break; } jingleIq.Instruction.Reason = reason; } this.Stream.Write(jingleIq); }
/// <summary> /// Constructs a Jingle IQ Paquet containing Jingle most common arguments /// </summary> /// <param name="to">Recipient of this Jingle IQ Paquet</param> /// <param name="action">Type of Action this request is about</param> /// <param name="sid"> /// SID of the session which can be created using JingleUtilities.GenerateSid for a session-initiate /// paquet construction or was given by a peer who initiated a session which had been accepted /// </param> /// <param name="contentName">The name of the content, only for informative purposes but mandatory</param> /// <param name="description">An XML element using root tag <description></description></param> /// <param name="transport">An XML element using root tag <transport></transport></param> /// <returns></returns> public JingleIQ SessionRequest(JID to, ActionType action, String sid, String contentName, Element description, Element transport) { JingleIQ jingleIq; if (description != null) jingleIq = new JingleIQ(description.OwnerDocument); else if (transport != null) jingleIq = new JingleIQ(transport.OwnerDocument); else jingleIq = new JingleIQ(new XmlDocument()); jingleIq.From = this.Stream.JID; jingleIq.To = to; jingleIq.Type = IQType.set; jingleIq.Instruction.Action = action; jingleIq.Instruction.Sid = sid; if (action == ActionType.session_initiate) jingleIq.Instruction.Initiator = this.Stream.JID; else if (action == ActionType.session_accept) jingleIq.Instruction.Responder = this.Stream.JID; if (!String.IsNullOrEmpty(contentName)) { JingleContent jcnt = jingleIq.Instruction.AddContent(contentName); if (description != null) jcnt.AddChild(description); if (transport != null) jcnt.AddChild(transport); } else { throw new InvalidOperationException("Content name cannot be null or an empty string"); } return jingleIq; }
/// <summary> /// TODO: Documentation SessionInfo /// </summary> /// <param name="to"></param> /// <param name="sid"></param> /// <param name="payload"></param> /// <returns></returns> public void SessionInfo(JID to, String sid, Element payload) { JingleIQ jingleIq; if (payload != null) jingleIq = new JingleIQ(payload.OwnerDocument); else jingleIq = new JingleIQ(this.Stream.Document); jingleIq.From = this.Stream.JID; jingleIq.To = to; jingleIq.Type = IQType.set; jingleIq.Instruction.Action = ActionType.session_info; jingleIq.Instruction.Sid = sid; if (payload != null) jingleIq.Instruction.AddChild(payload); this.Stream.Write(jingleIq); }