示例#1
0
 internal void FireSessionTransportInfoReceived(string strSession, GoogleTalkIQ iq)
 {
     if (OnSessionTransportInfoReceived != null)
     {
         OnSessionTransportInfoReceived(strSession, iq, XMPPClient);
     }
 }
示例#2
0
 internal void FireNewSession(string strSession, GoogleTalkIQ iq)
 {
     if (OnNewSession != null)
     {
         OnNewSession(strSession, iq, XMPPClient);
     }
 }
示例#3
0
 internal void FireSessionAcceptedReceived(string strSession, GoogleTalkIQ iq)
 {
     if (OnSessionAcceptedReceived != null)
     {
         OnSessionAcceptedReceived(strSession, iq, XMPPClient);
     }
 }
示例#4
0
        internal void SendGoogleSession(GoogleSession jingleinfo)
        {
            GoogleTalkIQ iq = new GoogleTalkIQ();

            iq.From        = XMPPClient.JID;
            iq.To          = RemoteJID;
            iq.Type        = IQType.set.ToString();
            iq.Session     = jingleinfo;
            iq.Session.SID = this.SessionId;

            XMPPClient.SendObject(iq);
        }
示例#5
0
        internal void TerminateSession(TerminateReason reason)
        {
            TerminateSessionRequest                   = new GoogleTalkIQ();
            TerminateSessionRequest.From              = XMPPClient.JID;
            TerminateSessionRequest.To                = RemoteJID;
            TerminateSessionRequest.Type              = IQType.set.ToString();
            TerminateSessionRequest.Session.Action    = GoogleSession.Terminate;
            TerminateSessionRequest.Session.Initiator = XMPPClient.JID;
            TerminateSessionRequest.Session.SID       = this.SessionId;
            //TerminateSessionRequest.Jingle.Reason = new Reason(reason);

            XMPPClient.SendObject(TerminateSessionRequest);
        }
示例#6
0
        internal void NewIncomingSessionRequest(GoogleTalkIQ iq)
        {
            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);

            GoogleTalkSessionManager.FireNewSession(this.SessionId, iq);
        }
示例#7
0
        internal void AcceptSession(GoogleSession 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 GoogleTalkIQ();
            AcceptSessionMessage.From              = XMPPClient.JID;
            AcceptSessionMessage.To                = RemoteJID;
            AcceptSessionMessage.Type              = IQType.set.ToString();
            AcceptSessionMessage.Session           = jingleinfo;
            AcceptSessionMessage.Session.Action    = GoogleSession.Accept;
            AcceptSessionMessage.Session.Initiator = XMPPClient.JID;
            AcceptSessionMessage.Session.SID       = this.SessionId;

            XMPPClient.SendObject(AcceptSessionMessage);
        }
示例#8
0
        internal void InitiateSession(GoogleSession 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 GoogleTalkIQ();
            OutgoingRequestMessage.From              = XMPPClient.JID;
            OutgoingRequestMessage.To                = RemoteJID;
            OutgoingRequestMessage.Type              = IQType.set.ToString();
            OutgoingRequestMessage.Session           = jingleinfo;
            OutgoingRequestMessage.Session.Action    = GoogleSession.Initiate;
            OutgoingRequestMessage.Session.Initiator = XMPPClient.JID;
            if (OutgoingRequestMessage.Session.SID == null)
            {
                OutgoingRequestMessage.Session.SID = Guid.NewGuid().ToString();
            }

            XMPPClient.SendObject(OutgoingRequestMessage);
        }
示例#9
0
        internal void TerminateSession(TerminateReason reason)
        {
            TerminateSessionRequest = new GoogleTalkIQ();
            TerminateSessionRequest.From = XMPPClient.JID;
            TerminateSessionRequest.To = RemoteJID;
            TerminateSessionRequest.Type = IQType.set.ToString();
            TerminateSessionRequest.Session.Action = GoogleSession.Terminate;
            TerminateSessionRequest.Session.Initiator = XMPPClient.JID;
            TerminateSessionRequest.Session.SID = this.SessionId;
            //TerminateSessionRequest.Jingle.Reason = new Reason(reason);

            XMPPClient.SendObject(TerminateSessionRequest);
        }
示例#10
0
        internal void SendGoogleSession(GoogleSession jingleinfo)
        {
            GoogleTalkIQ iq = new GoogleTalkIQ();
            iq.From = XMPPClient.JID;
            iq.To = RemoteJID;
            iq.Type = IQType.set.ToString();
            iq.Session = jingleinfo;
            iq.Session.SID = this.SessionId;

            XMPPClient.SendObject(iq);
        }
示例#11
0
        internal void NewIncomingSessionRequest(GoogleTalkIQ iq)
        {
            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);

            GoogleTalkSessionManager.FireNewSession(this.SessionId, iq);
        }
示例#12
0
        internal void InitiateSession(GoogleSession 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 GoogleTalkIQ();
            OutgoingRequestMessage.From = XMPPClient.JID;
            OutgoingRequestMessage.To = RemoteJID;
            OutgoingRequestMessage.Type = IQType.set.ToString();
            OutgoingRequestMessage.Session = jingleinfo;
            OutgoingRequestMessage.Session.Action = GoogleSession.Initiate;
            OutgoingRequestMessage.Session.Initiator = XMPPClient.JID;
            if (OutgoingRequestMessage.Session.SID == null)
                OutgoingRequestMessage.Session.SID = Guid.NewGuid().ToString();

            XMPPClient.SendObject(OutgoingRequestMessage);
        }
示例#13
0
        internal void AcceptSession(GoogleSession 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 GoogleTalkIQ();
            AcceptSessionMessage.From = XMPPClient.JID;
            AcceptSessionMessage.To = RemoteJID;
            AcceptSessionMessage.Type = IQType.set.ToString();
            AcceptSessionMessage.Session = jingleinfo;
            AcceptSessionMessage.Session.Action = GoogleSession.Accept;
            AcceptSessionMessage.Session.Initiator = XMPPClient.JID;
            AcceptSessionMessage.Session.SID = this.SessionId;

            XMPPClient.SendObject(AcceptSessionMessage);
        }
示例#14
0
        public void NewJingleIQ(GoogleTalkIQ gtiq)
        {
            /// New message coming in, see if it is session accept or session terminate
            ///
            if (gtiq.Type == IQType.error.ToString())
            {
                GoogleTalkSessionManager.FireSessionTerminated(this.SessionId);
                return;
            }

            if (gtiq.Type == IQType.set.ToString())
            {
                if (gtiq.Type == GoogleSession.Accept)
                {
                    IQ iqresponse = new IQ();
                    iqresponse.ID = gtiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = gtiq.From;
                    iqresponse.Type = IQType.result.ToString();
                    XMPPClient.SendXMPP(iqresponse);

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

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

                    this.IsCompleted = true;
                }
                else if (gtiq.Type == GoogleSession.TransportInfo)
                {

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

                    GoogleTalkSessionManager.FireSessionTransportInfoReceived(this.SessionId, gtiq);
                }
                else
                {
                    IQ iqresponse = new IQ();
                    iqresponse.ID = gtiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To = gtiq.From;
                    iqresponse.Type = IQType.error.ToString();
                    iqresponse.Error = new Error("<Unknown action />");

                    XMPPClient.SendXMPP(iqresponse);
                }
            }
        }
示例#15
0
        public override bool NewIQ(IQ iq)
        {
            if (iq is GoogleTalkIQ) //Our XMPPMessageFactory created a jingle message
            {
                /// See if this is a JINGLE message for our session
                ///
                GoogleTalkIQ jingleiq     = iq as GoogleTalkIQ;
                string       strSessionId = jingleiq.Session.SID;

                GoogleTalkLogic sessionlogic = null;
                lock (SessionLock)
                {
                    if (Sessions.ContainsKey(strSessionId) == true)
                    {
                        sessionlogic = Sessions[strSessionId];
                    }
                }

                if (sessionlogic != null)
                {
                    sessionlogic.NewJingleIQ(jingleiq);

                    if (sessionlogic.IsCompleted == true)
                    {
                        RemoveSesion(strSessionId);
                    }

                    return(true);
                }

                if (jingleiq.Session.Action == GoogleSession.Initiate)
                {
                    GoogleTalkLogic newrequestlogic = new GoogleTalkLogic(this.XMPPClient, strSessionId, this);
                    lock (SessionLock)
                    {
                        Sessions.Add(jingleiq.Session.SID, newrequestlogic);
                    }
                    newrequestlogic.NewIncomingSessionRequest(jingleiq);

                    if (newrequestlogic.IsCompleted == true)
                    {
                        RemoveSesion(strSessionId);
                    }

                    return(true);
                }
            }
            else
            {
                /// May be a simple response to one of our jingle objects, send the message to each one to see
                ///

                List <GoogleTalkLogic> sessions = new List <GoogleTalkLogic>();
                lock (SessionLock)
                {
                    foreach (string strSessionId in Sessions.Keys)
                    {
                        sessions.Add(Sessions[strSessionId]);
                    }
                }

                foreach (GoogleTalkLogic session in sessions)
                {
                    bool bHandled = session.NewIQ(iq);
                    if (bHandled == true)
                    {
                        if (session.IsCompleted == true)
                        {
                            RemoveSesion(session.SessionId);
                        }

                        return(true);
                    }
                }
            }

            return(false);
        }
示例#16
0
        public void NewJingleIQ(GoogleTalkIQ gtiq)
        {
            /// New message coming in, see if it is session accept or session terminate
            ///
            if (gtiq.Type == IQType.error.ToString())
            {
                GoogleTalkSessionManager.FireSessionTerminated(this.SessionId);
                return;
            }

            if (gtiq.Type == IQType.set.ToString())
            {
                if (gtiq.Type == GoogleSession.Accept)
                {
                    IQ iqresponse = new IQ();
                    iqresponse.ID   = gtiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To   = gtiq.From;
                    iqresponse.Type = IQType.result.ToString();
                    XMPPClient.SendXMPP(iqresponse);

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

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

                    this.IsCompleted = true;
                }
                else if (gtiq.Type == GoogleSession.TransportInfo)
                {
                    IQ iqresponse = new IQ();
                    iqresponse.ID   = gtiq.ID;
                    iqresponse.From = XMPPClient.JID;
                    iqresponse.To   = gtiq.From;
                    iqresponse.Type = IQType.result.ToString();
                    XMPPClient.SendXMPP(iqresponse);

                    GoogleTalkSessionManager.FireSessionTransportInfoReceived(this.SessionId, gtiq);
                }
                else
                {
                    IQ iqresponse = new IQ();
                    iqresponse.ID    = gtiq.ID;
                    iqresponse.From  = XMPPClient.JID;
                    iqresponse.To    = gtiq.From;
                    iqresponse.Type  = IQType.error.ToString();
                    iqresponse.Error = new Error("<Unknown action />");

                    XMPPClient.SendXMPP(iqresponse);
                }
            }
        }