Ejemplo n.º 1
0
 void JingleSessionManager_OnSessionTransportInfoReceived(string strSession, System.Net.XMPP.Jingle.JingleIQ jingle, System.Net.XMPP.XMPPClient client)
 {
     if ((MediaSession != null) && (MediaSession.Session == strSession))
     {
         MediaSession.GotTransportInfo(jingle);
     }
 }
Ejemplo n.º 2
0
 void JingleSessionManager_OnSessionAcceptedReceived(string strSession, System.Net.XMPP.Jingle.JingleIQ jingle, System.Net.XMPP.XMPPClient client)
 {
     Console.WriteLine("Session {0} has accepted our invitation", strSession);
     if ((MediaSession != null) && (MediaSession.Session == strSession))
     {
         MediaSession.SessionAccepted(jingle, null);
         StartMedia();
     }
 }
Ejemplo n.º 3
0
        void JingleSessionManager_OnNewSession(string strSession, System.Net.XMPP.Jingle.JingleIQ iq, System.Net.XMPP.XMPPClient client)
        {
            App.XMPPClient.JingleSessionManager.TerminateSession(strSession, TerminateReason.Decline);
            //bool bAcceptNewCall = (bool)this.Dispatcher.Invoke(new DelegateAcceptSession(ShouldAcceptSession), strSession, jingle);

            //if (bAcceptNewCall == true)
            //{
            //    int nPort = GetNextPort();
            //    IPEndPoint ep = new IPEndPoint(addresses[0], nPort);

            //    JingleMediaSession session = new JingleMediaSession(strSession, jingle, ep, client);
            //    session.UseStun = UseStun;
            //    session.SendAcceptSession();
            //    SessionList.Add(strSession, session);
            //    ObservSessionList.Add(session);
            //}
            //else
            //{
            //    XMPPClient.JingleSessionManager.TerminateSession(strSession, TerminateReason.Decline);
            //}
        }
Ejemplo n.º 4
0
        void FireNewSessionThreaded(object obj)
        {
            JingleIQ iq = obj as JingleIQ;
            IncomingRequestMessage = iq;
            RemoteJID = iq.From;

            IQ iqresponse = new IQ();
            iqresponse.ID = IncomingRequestMessage.ID;
            iqresponse.From = XMPPClient.JID;
            iqresponse.To = IncomingRequestMessage.From;

            iqresponse.Type = IQType.result.ToString();
            XMPPClient.SendXMPP(iqresponse);

            JingleSessionManager.FireNewSession(this.SessionId, iq);
        }
Ejemplo n.º 5
0
        internal void TerminateSession(TerminateReason reason)
        {
            TerminateSessionRequest = new JingleIQ();
            TerminateSessionRequest.From = XMPPClient.JID;
            TerminateSessionRequest.To = RemoteJID;
            TerminateSessionRequest.Type = IQType.set.ToString();
            TerminateSessionRequest.Jingle.Action = Jingle.SessionTerminate;
            TerminateSessionRequest.Jingle.Initiator = XMPPClient.JID;
            TerminateSessionRequest.Jingle.SID = this.SessionId;
            TerminateSessionRequest.Jingle.Reason = new Reason(reason);

            XMPPClient.SendObject(TerminateSessionRequest);
        }
Ejemplo n.º 6
0
        internal void SendTransportInfo(Jingle jingle)
        {
            TransportInfoRequest = new JingleIQ();
            TransportInfoRequest.From = XMPPClient.JID;
            TransportInfoRequest.To = RemoteJID;
            TransportInfoRequest.Type = IQType.set.ToString();
            TransportInfoRequest.Jingle = jingle;
            TransportInfoRequest.Jingle.Action = Jingle.TransportInfo;
            TransportInfoRequest.Jingle.SID = this.SessionId;

            XMPPClient.SendObject(TransportInfoRequest);
        }
Ejemplo n.º 7
0
        internal void SendJingle(Jingle jingleinfo)
        {
            JingleIQ iq = new JingleIQ();
            iq.From = XMPPClient.JID;
            iq.To = RemoteJID;
            iq.Type = IQType.set.ToString();
            iq.Jingle = jingleinfo;
            iq.Jingle.SID = this.SessionId;

            XMPPClient.SendObject(iq);
        }
Ejemplo n.º 8
0
        internal void NewIncomingSessionRequest(JingleIQ iq)
        {
            /// Handle this in a different thread so the we can still process xmpp messages but the user can reply at will
            ///

            System.Threading.ThreadPool.QueueUserWorkItem(new Threading.WaitCallback(FireNewSessionThreaded), iq);
        }
Ejemplo n.º 9
0
        internal void InitiateSession(Jingle jingleinfo, string strJIDTo)
        {
            if (OutgoingRequestMessage != null) /// we've already started a session, the user needs to create a new one
                throw new Exception(string.Format("Cannot initiate a session that already exists, Session [{0}] has already sent out an initiate session message, client must create a new session", this.SessionId));

            RemoteJID = strJIDTo;

            OutgoingRequestMessage = new JingleIQ();
            OutgoingRequestMessage.From = XMPPClient.JID;
            OutgoingRequestMessage.To = RemoteJID;
            OutgoingRequestMessage.Type = IQType.set.ToString();
            OutgoingRequestMessage.Jingle = jingleinfo;
            OutgoingRequestMessage.Jingle.Action = Jingle.SessionInitiate;
            OutgoingRequestMessage.Jingle.Initiator = XMPPClient.JID;
            if (OutgoingRequestMessage.Jingle.SID == null)
               OutgoingRequestMessage.Jingle.SID = Guid.NewGuid().ToString();

            XMPPClient.SendObject(OutgoingRequestMessage);
        }
Ejemplo n.º 10
0
        internal void AcceptSession(Jingle jingleinfo)
        {
            if (AcceptSessionMessage != null) /// we've already started a session, the user needs to create a new one
                throw new Exception(string.Format("Cannot accept a session that already exists, Session [{0}] has already been accepted, client must create a new session", this.SessionId));

            AcceptSessionMessage = new JingleIQ();
            AcceptSessionMessage.From = XMPPClient.JID;
            AcceptSessionMessage.To = RemoteJID;
            AcceptSessionMessage.Type = IQType.set.ToString();
            AcceptSessionMessage.Jingle = jingleinfo;
            AcceptSessionMessage.Jingle.Action = Jingle.SessionAccept;
            //AcceptSessionMessage.Jingle.Initiator = XMPPClient.JID;
            AcceptSessionMessage.Jingle.SID = this.SessionId;

            XMPPClient.SendObject(AcceptSessionMessage);
        }
Ejemplo n.º 11
0
        public void NewJingleIQ(JingleIQ jingleiq)
        {
            /// New message coming in, see if it is session accept or session terminate
            ///
            if (jingleiq.Type == IQType.error.ToString())
            {
                JingleSessionManager.FireSessionTerminated(this.SessionId);
                return;
            }

            if (jingleiq.Type == IQType.set.ToString())
            {
                if ((jingleiq.Jingle.Action == Jingle.SessionAccept)||(jingleiq.Jingle.Action == Jingle.Accept))
                {
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();
                    XMPPClient.SendXMPP(iqresponse);

                    JingleSessionManager.FireSessionAcceptedReceived(this.SessionId, jingleiq);
                }
                else if ((jingleiq.Jingle.Action == Jingle.SessionTerminate)||(jingleiq.Jingle.Action == Jingle.Terminate))
                {
                    /// Tell the user we've been terminated.  Ack and finish this logic
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                    JingleSessionManager.FireSessionTerminated(this.SessionId);

                    this.IsCompleted = true;
                }
                else if (jingleiq.Jingle.Action == Jingle.ContentAdd)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else if (jingleiq.Jingle.Action == Jingle.ContentModify)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else if (jingleiq.Jingle.Action == Jingle.ContentReject)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else if (jingleiq.Jingle.Action == Jingle.ContentAccept)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else if (jingleiq.Jingle.Action == Jingle.DescriptionInfo)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else if (jingleiq.Jingle.Action == Jingle.SessionInfo)
                {
                    //if (jingleiq.Jingle.JingleStateChange != JingleStateChange.None)

                    /// Some type of status message, just ack
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);

                    /// TODO, notify client of state change
                    ///
                    System.Diagnostics.Debug.WriteLine("Got a Jingle state changed event of {0}", jingleiq.Jingle.JingleStateChange);
                }
                else if (jingleiq.Jingle.Action == Jingle.TransportInfo)
                {

                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();
                    XMPPClient.SendXMPP(iqresponse);

                    JingleSessionManager.FireSessionTransportInfoReceived(this.SessionId, jingleiq);
                }
                else if (jingleiq.Jingle.Action == Jingle.TransportAccept)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else if (jingleiq.Jingle.Action == Jingle.TransportReject)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else if (jingleiq.Jingle.Action == Jingle.TransportReplace)
                {
                    /// TODO, notify user of this
                    ///
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.result.ToString();

                    XMPPClient.SendXMPP(iqresponse);
                }
                else
                {
                    IQ iqresponse = new IQ();
                    iqresponse.ID = jingleiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = jingleiq.From;
                    iqresponse.Type = IQType.error.ToString();
                    iqresponse.Error = new Error("<Unknown action />");

                    XMPPClient.SendXMPP(iqresponse);
                }
            }
        }