Exemple #1
0
        protected override void AttachUccSession(IUccSession uccSession)
        {
            base.AttachUccSession(uccSession);

            this.uccImSession = (IUccInstantMessagingSession)this.UccSession;
            ComEvents.Advise <_IUccInstantMessagingSessionEvents>(this.uccImSession, this);
        }
Exemple #2
0
        protected override void OnParticipantAdded(IUccSession eventSource, IUccSessionParticipant participant)
        {
            base.OnParticipantAdded(eventSource, participant);

            if (participant.IsLocal == false)
            {
                ComEvents.Advise <_IUccInstantMessagingSessionParticipantEvents>(participant, this);
            }
        }
        void _IUccSessionManagerEvents.OnOutgoingSession(
            IUccEndpoint eventSource,
            UccOutgoingSessionEvent eventData)
        {
            this.outSession = eventData.Session;
            this.sessionList.Add(eventData.Session);

            // register for generice events
            Advise <_IUccSessionEvents>(eventData.Session, this);
            Advise <_IUccSessionParticipantCollectionEvents>(eventData.Session, this);
        }
        public void OnInstantMessageReceived(UccInstantMessagingSessionParticipant pEventSource, UccIncomingInstantMessageEvent pEventData)
        {
            IUccSession session = null;

            if (this._sessions.TryGetValue(pEventData.ParticipantEndpoint.Uri.Value.ToLower(), out session))
            {
                if (MessageReceived != null)
                {
                    MessageReceived(session as IUccInstantMessagingSession, pEventData);
                }
            }
        }
Exemple #5
0
        void _IUccSessionEvents.OnRemoveParticipant(IUccSession eventSource, IUccOperationProgressEvent eventData)
        {
            ParticipantLog log = this.GetPartipantLog(GetParticipantUri(eventData.OriginalOperationContext.Context));

            if (Helpers.IsOperationCompleteFailed(eventData))
            {
                log.SetState(PartipantLogState.RemoveFailed, eventData.StatusCode);
            }
            if (Helpers.IsOperationCompleteOk(eventData))
            {
                log.State = PartipantLogState.RemoveSuccess;
            }
        }
Exemple #6
0
        protected override void OnParticipantAdded(IUccSession eventSource, IUccSessionParticipant participant)
        {
            base.OnParticipantAdded(eventSource, participant);

            IUccAudioVideoSessionParticipant avParticipant = participant as IUccAudioVideoSessionParticipant;

            foreach (IUccMediaChannel channel in avParticipant.Channels)
            {
                this.OnChannelAdded(avParticipant, channel);
            }

            ComEvents.Advise <_IUccMediaChannelCollectionEvents>(avParticipant, this);
        }
Exemple #7
0
        /// <summary>
        /// Register related events when participant has been added
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionParticipantCollectionEvents.OnParticipantAdded(
            IUccSession eventSource,
            UccSessionParticipantCollectionEvent eventData)
        {
            if (eventData.Participant.IsLocal)
            {
                return;
            }

            Advise <_IUccSessionParticipantEvents>(eventData.Participant, this);
            if (eventSource.Type == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING)
            {
                Advise <_IUccInstantMessagingSessionParticipantEvents>(eventData.Participant, this);
            }
        }
Exemple #8
0
        protected virtual void DetachUccSession(bool terminate)
        {
            if (this.uccSession != null)
            {
                ComEvents.UnadviseAll(this);
                if (terminate)
                {
                    this.uccSession.Terminate(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE, null);
                }
                this.uccSession = null;

                foreach (ParticipantLog log in this.PartipantLogs)
                {
                    log.State = PartipantLogState.SessionTerminated;
                }
            }
        }
Exemple #9
0
        /// <summary>
        /// Handle OnStateChanged events. Set the buttons in mainform to appropriate state
        /// when the session is connected or disconnected
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionParticipantEvents.OnStateChanged(
            IUccSessionParticipant eventSource,
            UccSessionParticipantStateChangedEvent eventData)
        {
            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_CONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                    this.mainForm.SetIMOff();
                    this.mainForm.WriteStatusMessage("IM session is connected to " + eventSource.Uri);
                    break;

                case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                    this.mainForm.SetVoIPOff();
                    this.mainForm.WriteStatusMessage("AV session is connected to " + eventSource.Uri);
                    break;

                default:
                    break;
                }
            }

            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_DISCONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                    this.imSession = null;
                    this.mainForm.SetIMOn();
                    this.mainForm.WriteStatusMessage("IM session is disconnected.");
                    break;

                case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                    this.avSession = null;
                    this.mainForm.SetVoipOn();
                    this.mainForm.WriteStatusMessage("AV Session is disconnected");
                    break;

                default:
                    return;
                }
            }
        }
Exemple #10
0
        protected virtual void AttachUccSession(IUccSession uccSession)
        {
            foreach (IUccSessionParticipant uccParticipant in uccSession.Participants)
            {
                //if (this.FindParticipantLog(uccParticipant.Uri.Value) == null)
                //ComEvents.Advise<_IUccSessionParticipantEvents>(uccParticipant, this);
                this.OnParticipantAdded(uccSession, uccParticipant);
                this.GetPartipantLog(uccParticipant).SetState(uccParticipant.State);
            }

            foreach (ParticipantLog log in this.PartipantLogs)
            {
                if (log.IsLocal)
                {
                    log.State = PartipantLogState.Local;
                }
            }

            this.uccSession = uccSession;
            ComEvents.Advise <_IUccSessionEvents>(this.uccSession, this);
            ComEvents.Advise <_IUccSessionParticipantCollectionEvents>(this.uccSession, this);

            foreach (ParticipantLog log in this.PartipantLogs)
            {
                if (log.IsLocal == false)
                {
                    bool exist = false;
                    foreach (IUccSessionParticipant uccParticipant in uccSession.Participants)
                    {
                        if (Helpers.IsUriEqual(log.Uri, uccParticipant.Uri.Value))
                        {
                            exist = true;
                        }
                    }

                    if (exist == false)
                    {
                        this.AddPartipant(log.Uri);
                    }
                }
            }
        }
        /// <summary>
        /// Create Session with appropriate session type
        /// </summary>
        /// <param name="sessionType"></param>
        public void CreateSession(UCC_SESSION_TYPE sessionType)
        {
            // Create Session
            IUccSessionManager sessionManager = this.endpoint as IUccSessionManager;
            IUccSession session = sessionManager.CreateSession(sessionType, null);

            // Register to receive events
            if (sessionType == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING)
            {
                this.imSession = session;
                // Advise for InstantMessagingSession Events
                Advise<_IUccInstantMessagingSessionEvents>(session, this);
            }
            else if (sessionType == UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO)
            {
                this.avSession = session;
            }

            // Advise for SessionParticipantCollectionEvents & SessionEvents
            Advise<_IUccSessionParticipantCollectionEvents>(session, this);
            Advise<_IUccSessionEvents>(session, this);
        }
Exemple #12
0
        /// <summary>
        /// Create Session with appropriate session type
        /// </summary>
        /// <param name="sessionType"></param>
        public void CreateSession(UCC_SESSION_TYPE sessionType)
        {
            // Create Session
            IUccSessionManager sessionManager = this.endpoint as IUccSessionManager;
            IUccSession        session        = sessionManager.CreateSession(sessionType, null);

            // Register to receive events
            if (sessionType == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING)
            {
                this.imSession = session;
                // Advise for InstantMessagingSession Events
                Advise <_IUccInstantMessagingSessionEvents>(session, this);
            }
            else if (sessionType == UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO)
            {
                this.avSession = session;
            }

            // Advise for SessionParticipantCollectionEvents & SessionEvents
            Advise <_IUccSessionParticipantCollectionEvents>(session, this);
            Advise <_IUccSessionEvents>(session, this);
        }
Exemple #13
0
        /// <summary>
        /// Handle OnAddParticipant events. Display when it fails to add the participant.
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionEvents.OnAddParticipant(
            IUccSession eventSource,
            IUccOperationProgressEvent eventData)
        {
            if (eventData.IsComplete && eventData.StatusCode < 0)
            {
                switch (eventSource.Type)
                {
                case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                    this.imSession = null;
                    this.mainForm.WriteStatusMessage("IM Session failed to connect to " + this.imRemoteUri);
                    break;

                case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                    this.avSession = null;
                    this.mainForm.WriteStatusMessage("AV Session failed to connect to " + this.avRemoteUri);
                    break;

                default:
                    break;
                }
            }
        }
        public void SendNewMessage(string user, string msg)
        {
            IUccSession session = null;

            if (!this._sessions.TryGetValue(user.ToLower(), out session))
            {
                var    context        = new UccContext();
                UccUri participantUri = this._uriManager.ParseUri("sip:[email protected]");

                session = this._sessionManager.CreateSession(UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING, context);
                var p = session.CreateParticipant(participantUri, null);

                Advise <_IUccInstantMessagingSessionParticipantEvents>(p, this);
                session.AddParticipant(p, null);

                Advise <_IUccSessionEvents>(session, this);

                this._sessions.Add(user.ToLower(), session);
            }

            IUccInstantMessagingSession ims = session as IUccInstantMessagingSession;

            ims.SendMessage("text/plain", msg, null);
        }
Exemple #15
0
        /// <summary>
        /// Process Incoming Session request
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionManagerEvents.OnIncomingSession(
            IUccEndpoint eventSource,
            UccIncomingSessionEvent eventData)
        {
            DialogResult result;

            // Handle incoming IM session
            if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING)
            {
                // The App only support one active IM session. Reject incoming IM session request
                // if there is already an active IM session.
                if (this.imSession != null)
                {
                    MessageBox.Show("There is an active IM session. This Application only supports one active IM session right now. " +
                                    "The App is rejecting incoming session from " + eventData.Inviter.Uri + ".");
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }

                // Ask user he wants to accept the incoming requet.
                result = MessageBox.Show("Accept incoming IM session from " + eventData.Inviter.Uri + "?",
                                         "Incoming Session", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }

                // Register to receive events
                this.imSession   = eventData.Session;
                this.imRemoteUri = eventData.Inviter.Uri.AddressOfRecord;
                Advise <_IUccInstantMessagingSessionEvents>(this.imSession, this);
                foreach (IUccSessionParticipant oneParticipant in this.imSession.Participants)
                {
                    if (oneParticipant != null && !oneParticipant.IsLocal)
                    {
                        Advise <_IUccInstantMessagingSessionParticipantEvents>(oneParticipant, this);
                        Advise <_IUccSessionParticipantEvents>(oneParticipant, this);
                    }
                }
            }
            // Handle incoming AV session
            else if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO)
            {
                // Reject incoming AV session request if there is already an active av session.
                if (this.avSession != null)
                {
                    MessageBox.Show("There is an AV active session. We only supports one active session right now. " +
                                    "The App is rejecting incoming session from " +
                                    eventData.Inviter.Uri + ".");
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }

                result = MessageBox.Show("Accept incoming AV session from " + eventData.Inviter.Uri + "?",
                                         "Incoming Session", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }

                // Register to receive events
                this.avRemoteUri = eventData.Inviter.Uri.AddressOfRecord;
                this.avSession   = eventData.Session;

                foreach (IUccSessionParticipant oneParticipant in this.avSession.Participants)
                {
                    if (oneParticipant != null && !oneParticipant.IsLocal)
                    {
                        Advise <_IUccSessionParticipantEvents>(oneParticipant, this);
                    }
                }
            }
            else
            {
                eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                return;
            }

            // register for generice events
            Advise <_IUccSessionEvents>(eventData.Session, this);
            Advise <_IUccSessionParticipantCollectionEvents>(eventData.Session, this);

            // Accept incoming session
            eventData.Accept();
        }
        void _IUccSessionManagerEvents.OnOutgoingSession(
                        IUccEndpoint eventSource,
                        UccOutgoingSessionEvent eventData)
        {
            this.outSession = eventData.Session;
            this.sessionList.Add(eventData.Session);

            // register for generice events
            Advise<_IUccSessionEvents>(eventData.Session, this);
            Advise<_IUccSessionParticipantCollectionEvents>(eventData.Session, this);
        }
Exemple #17
0
 void _IUccSessionParticipantCollectionEvents.OnParticipantAdded(IUccSession eventSource, UccSessionParticipantCollectionEvent eventData)
 {
     this.OnParticipantAdded(eventSource, eventData.Participant);
 }
        /// <summary>
        /// Handle OnStateChanged events. Set the buttons in mainform to appropriate state
        /// when the session is connected or disconnected
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionParticipantEvents.OnStateChanged(
                        IUccSessionParticipant eventSource,
                        UccSessionParticipantStateChangedEvent eventData)
        {
            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_CONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                    case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                        this.mainForm.SetIMOff();
                        this.mainForm.WriteStatusMessage("IM session is connected to " + eventSource.Uri);
                        break;

                    case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                        this.mainForm.SetVoIPOff();
                        this.mainForm.WriteStatusMessage("AV session is connected to " + eventSource.Uri);
                        break;

                    default:
                        break;

                }
            }

            if (eventData.NewState == UCC_SESSION_ENTITY_STATE.UCCSES_DISCONNECTED)
            {
                switch (eventSource.Session.Type)
                {
                    case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                        this.imSession = null;
                        this.mainForm.SetIMOn();
                        this.mainForm.WriteStatusMessage("IM session is disconnected.");
                        break;

                    case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                        this.avSession = null;
                        this.mainForm.SetVoipOn();
                        this.mainForm.WriteStatusMessage("AV Session is disconnected");
                        break;

                    default:
                        return;
                }
            }
        }
        /// <summary>
        /// Process Incoming Session request
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionManagerEvents.OnIncomingSession(
                            IUccEndpoint eventSource,
                            UccIncomingSessionEvent eventData)
        {
            DialogResult result;

            // Handle incoming IM session
            //eventSource.
            if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING)
            {
                // The App only support one active IM session. Reject incoming IM session request
                // if there is already an active IM session.
                if (this.imSession != null)
                {
                    MessageBox.Show("There is an active IM session. This Application only supports one active IM session right now. " +
                            "The App is rejecting incoming session from " + eventData.Inviter.Uri + ".");
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }

                // Ask user he wants to accept the incoming requet.
                result = MessageBox.Show("Accept incoming IM session from " + eventData.Inviter.Uri + "?",
                                             "Incoming Session", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }

                // Register to receive events
                this.imSession = eventData.Session;
                this.imRemoteUri = eventData.Inviter.Uri.AddressOfRecord;
                Advise<_IUccInstantMessagingSessionEvents>(this.imSession, this);
                foreach (IUccSessionParticipant oneParticipant in this.imSession.Participants)
                {
                    if (oneParticipant != null && !oneParticipant.IsLocal)
                    {
                        Advise<_IUccInstantMessagingSessionParticipantEvents>(oneParticipant, this);
                        Advise<_IUccSessionParticipantEvents>(oneParticipant, this);
                    }
                }
            }
            // Handle incoming AV session
            else if (eventData.Session.Type == UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO)
            {
                //SetupAudioMicro();

                // Reject incoming AV session request if there is already an active av session.
                if (this.avSession != null)
                {
                    MessageBox.Show("There is an AV active session. We only supports one active session right now. " +
                            "The App is rejecting incoming session from " +
                            eventData.Inviter.Uri + ".");
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }
                //IUccSessionCallControl aa = eventData.Session as IUccSessionCallControl;
                //aa.
                //eventSource.

                result = MessageBox.Show("Accept incoming AV session from " + eventData.Inviter.Uri.User + "?",
                                             "Incoming Session", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                    return;
                }

                // Register to receive events
                this.avRemoteUri = eventData.Inviter.Uri.AddressOfRecord;
                this.avSession = eventData.Session;

                foreach (IUccSessionParticipant oneParticipant in this.avSession.Participants)
                {
                    if (oneParticipant != null && !oneParticipant.IsLocal)
                    {
                        Advise<_IUccSessionParticipantEvents>(oneParticipant, this);
                    }
                }
            }
            else
            {
                eventData.Reject(UCC_REJECT_OR_TERMINATE_REASON.UCCROTR_DECLINE);
                return;
            }

            // register for generice events
            Advise<_IUccSessionEvents>(eventData.Session, this);
            Advise<_IUccSessionParticipantCollectionEvents>(eventData.Session, this);

            // Accept incoming session
            eventData.Accept();
        }
Exemple #20
0
 void _IUccSessionEvents.OnTerminate(
     IUccSession eventSource,
     IUccOperationProgressEvent eventData)
 {
 }
Exemple #21
0
 public void OnIncomingTransfer(IUccSession pEventSource, UccIncomingSessionTransferEvent pEventData)
 {
     throw new NotImplementedException();
 }
Exemple #22
0
 protected override void AttachUccSession(IUccSession uccSession)
 {
     base.AttachUccSession(uccSession);
 }
        /// <summary>
        /// Handle OnAddParticipant events. Display when it fails to add the participant.
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionEvents.OnAddParticipant(
                        IUccSession eventSource,
                        IUccOperationProgressEvent eventData)
        {
            if (eventData.IsComplete && eventData.StatusCode < 0)
            {
                //eventData.StatusCode = 180;
                switch (eventSource.Type)
                {
                    case UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING:
                        this.imSession = null;
                        this.mainForm.WriteStatusMessage("IM Session failed to connect to " + this.imRemoteUri);
                        break;
                    case UCC_SESSION_TYPE.UCCST_AUDIO_VIDEO:
                        this.avSession = null;

                        this.mainForm.WriteStatusMessage("AV Session failed to connect to " + this.avRemoteUri);
                        break;
                    default:
                        break;
                }
            }
        }
 void _IUccSessionEvents.OnTerminate(
           IUccSession eventSource,
           IUccOperationProgressEvent eventData)
 {
     this.sessionList.Remove(eventSource);
 }
Exemple #25
0
 void _IUccSessionEvents.OnRemoveParticipant(
     IUccSession eventSource,
     IUccOperationProgressEvent eventData)
 {
 }
        /// <summary>
        /// Register related events when participant has been added
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>
        void _IUccSessionParticipantCollectionEvents.OnParticipantAdded(
                        IUccSession eventSource,
                        UccSessionParticipantCollectionEvent eventData)
        {
            if (eventData.Participant.IsLocal)
                return;

            Advise<_IUccSessionParticipantEvents>(eventData.Participant, this);
            if (eventSource.Type == UCC_SESSION_TYPE.UCCST_INSTANT_MESSAGING)
            {

                Advise<_IUccInstantMessagingSessionParticipantEvents>(eventData.Participant, this);
            }
        }
Exemple #27
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eventSource"></param>
        /// <param name="eventData"></param>

        void _IUccSessionParticipantCollectionEvents.OnParticipantRemoved(
            IUccSession eventSource,
            UccSessionParticipantCollectionEvent eventData)
        {
        }
Exemple #28
0
 void _IUccSessionEvents.OnTerminate(IUccSession eventSource, IUccOperationProgressEvent eventData)
 {
     this.DetachUccSession(false);
 }
 void _IUccSessionEvents.OnRemoveParticipant(
               IUccSession eventSource,
               IUccOperationProgressEvent eventData)
 {
 }
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventSource"></param>
 /// <param name="eventData"></param>
 void _IUccSessionParticipantCollectionEvents.OnParticipantRemoved(
                 IUccSession eventSource,
                 UccSessionParticipantCollectionEvent eventData)
 {
 }
Exemple #31
0
 public void OnAlternate(IUccSession pEventSource, IUccOperationProgressEvent pEventData)
 {
     throw new NotImplementedException();
 }
 void _IUccSessionEvents.OnTerminate(
     IUccSession eventSource,
     IUccOperationProgressEvent eventData)
 {
     this.sessionList.Remove(eventSource);
 }
Exemple #33
0
 public void OnTransferProgress(IUccSession pEventSource, UccSessionTransferProgressEvent pEventData)
 {
     throw new NotImplementedException();
 }
Exemple #34
0
        protected override void OnParticipantRemoved(IUccSession eventSource, IUccSessionParticipant participant)
        {
            base.OnParticipantRemoved(eventSource, participant);

            ComEvents.Unadvise <_IUccMediaChannelCollectionEvents>(participant, this);
        }