コード例 #1
0
 internal void HandleOnInvite(object sender, InviteEventArgs e)
 {
     if (OnInvite != null)
     {
         OnInvite(this, e);
     }
 }
コード例 #2
0
        public void OnInvite(object sender, InviteEventArgs e)
        {
            const string FlagRequired = Flags.BotManagement;

            this.flagService.GetFlagsForUser(e.User, e.Channel);
            CommandAclStatus aclStatus;

            var userIsAllowed = this.flagService.UserHasFlag(e.User, FlagRequired, e.Channel);

            if (!userIsAllowed)
            {
                aclStatus = CommandAclStatus.DeniedMain;
            }
            else
            {
                this.JoinChannel(e.Channel);
                aclStatus = CommandAclStatus.Allowed;
            }

            this.accessLogService.SaveLogEntry(
                this.GetType(),
                "INVITE " + e.Channel,
                e.User,
                "INVITE",
                FlagRequired,
                null,
                aclStatus);
        }
コード例 #3
0
 public override bool OnInvite(object sender, InviteEventArgs e)
 {
     if (e.Target == ((IrcClient)sender).Me.Nickname)
     {
         this.SendCheck(string.Format("Invited to \u0002{0}\u0002/\u0002{1}\u0002 by {2}{3}\u000F.", e.Channel, (sender as IrcClient).NetworkName, Colours.NicknameColour(e.Sender.Nickname), e.Sender.Nickname), (IrcClient)sender, e.Sender);
     }
     return(base.OnInvite(sender, e));
 }
コード例 #4
0
        void Invited(object sender, InviteEventArgs e)
        {
            log.Message("Received invite from {0} for {1}", e.Who, e.Channel);

            // Keep track of channels we're invited to, so that we may rejoin after disconnects.
            if (!currentChannels.Contains(e.Channel))
            {
                currentChannels.Add(e.Channel);
                irc.SendMessage(SendType.Notice, e.Who,
                                "If you want your channel on the auto-join list, please contact the owner.");
            }
        }
コード例 #5
0
ファイル: ListenerTests.cs プロジェクト: ortzinator/mutinyirc
        public void ProcessInviteCommand()
        {
            IrcMessage msg = new IrcMessage
            {
                Command = "INVITE",
                From    = _userString,
                Message = "#ortzirc"
            };
            InviteEventArgs givenArgs = null;

            _listener.OnInvite += delegate(object sender, InviteEventArgs args) { givenArgs = args; };
            _listener.ProcessInviteCommand(msg);
            Assert.AreEqual("#ortzirc", givenArgs.Channel);
            Assert.AreEqual("Ortzinator", givenArgs.Nick);
        }
コード例 #6
0
        private void sipService_onInviteEvent(object sender, InviteEventArgs e)
        {
            switch (e.Type)
            {
            case InviteEventTypes.INCOMING:
                Win32ServiceManager.SharedManager.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
                {
                    MediaActionHanler.ReceiveCall(e.GetExtra(InviteEventArgs.EXTRA_SESSION) as MyInviteSession);
                }, null);

                break;

            default:
                break;
            }
        }
コード例 #7
0
 private void sipService_onInviteEvent(object sender, InviteEventArgs e)
 {
     if (e.Type == InviteEventTypes.DISCONNECTED)
     {
         HistoryEvent @event;
         if ((@event = this.historyDataSource.FirstOrDefault(x => x.MediaType == BogheCore.MediaType.FileTransfer && x.SipSessionId == e.SessionId)) != null)
         {
             this.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
             {
                 this.historyService.AddEvent(@event);
             });
         }
         else if (this.ChatSession != null && this.ChatSession.Id == e.SessionId)
         {
             this.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
             {
                 this.ChatSession = null;
             });
         }
     }
 }
コード例 #8
0
 public UserInvitedToChannelEventArgs([NotNull] InviteEventArgs inviteArgs)
 {
     InviteArgs = inviteArgs;
     RawMessage = new RawMessageEventArgs(InviteArgs.Data);
 }
コード例 #9
0
ファイル: SessionWindow.SipEvent.cs プロジェクト: zzh56/boghe
        private void sipService_onInviteEvent(object sender, InviteEventArgs e)
        {
            if (this.AVSession == null || (this.AVSession.Id != e.SessionId && e.Type != InviteEventTypes.REMOTE_TRANSFER_INPROGESS))
            {
                /* Messaging */
                if (e.Type == InviteEventTypes.DISCONNECTED)
                {
                    if (this.historyDataSource.Any(x => x.SipSessionId == e.SessionId))
                    {
                        this.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
                        {
                            HistoryEvent @event = this.historyDataSource.FirstOrDefault(x => x.SipSessionId == e.SessionId);
                            if (@event != null)
                            {
                                this.historyService.AddEvent(@event);
                            }
                        }, null);
                    }
                    else if (this.ChatSession != null && this.ChatSession.Id == e.SessionId)
                    {
                        this.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
                        {
                            this.ChatSession = null;
                        });
                    }
                }
                return;
            }

            /* Audio/Video */

            if (this.Dispatcher.Thread != Thread.CurrentThread)
            {
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                            new EventHandler <InviteEventArgs>(this.sipService_onInviteEvent), sender, new object[] { e });
                return;
            }

            this.UpdateControls();

            switch (e.Type)
            {
            case InviteEventTypes.INCOMING:
            {
                this.labelInfo.Content     = String.Format("{0} {1}", Strings.Text_IncomingCall, this.AVSession.RemotePartyDisplayName);
                this.avHistoryEvent        = new HistoryAVCallEvent(this.AVSession.MediaType != BogheCore.MediaType.Audio, this.AVSession.RemotePartyUri);
                this.avHistoryEvent.Status = HistoryEvent.StatusType.Missed;
                break;
            }

            case InviteEventTypes.INPROGRESS:
            {
                // History Event
                this.labelInfo.Content = String.Format("{0}...", Strings.Text_CallInProgress);
                bool isVideo = ((this.AVSession.MediaType & MediaType.Video) == MediaType.Video || (this.AVSession.MediaType & MediaType.Videobfcp) == MediaType.Videobfcp);
                this.avHistoryEvent        = new HistoryAVCallEvent(isVideo, this.AVSession.RemotePartyUri);
                this.avHistoryEvent.Status = HistoryEvent.StatusType.Outgoing;
                if (isVideo)
                {
                    // Video Displays
                    this.AttachDisplays();
                }

                break;
            }

            case InviteEventTypes.RINGING:
            {
                this.labelInfo.Content = Strings.Text_Ringing;
                this.soundService.PlayRingBackTone();
                break;
            }

            case InviteEventTypes.EARLY_MEDIA:
            {
                this.labelInfo.Content = Strings.Text_EarlyMediaStarted;
                this.soundService.StopRingBackTone();
                this.soundService.StopRingTone();
                break;
            }

            case InviteEventTypes.MEDIA_UPDATING:
            {
                this.labelInfo.Content = "Trying to update media...";
                break;
            }

            case InviteEventTypes.MEDIA_UPDATED:
            {
                bool isVideo = ((this.AVSession.MediaType & MediaType.Video) == MediaType.Video || (this.AVSession.MediaType & MediaType.Videobfcp) == MediaType.Videobfcp);
                this.labelInfo.Content = String.Format("Media Updated - {0}", isVideo ? "Video" : "Audio");
                if (isVideo)
                {
                    this.AttachDisplays();
                }
                break;
            }

            case InviteEventTypes.CONNECTED:
            {
                this.labelInfo.Content = Strings.Text_InCall;
                this.soundService.StopRingBackTone();
                this.soundService.StopRingTone();

                this.videoDisplayLocal.Visibility          = ((this.AVSession.MediaType & MediaType.Video) == MediaType.Video) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
                this.videoDisplayScrenCastLocal.Visibility = ((this.AVSession.MediaType & MediaType.Videobfcp) == MediaType.Videobfcp) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
                this.videoDisplayRemote.Visibility         = ((this.AVSession.MediaType & MediaType.Video) == MediaType.Video) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;
                this.labelQuality.Visibility = ((this.AVSession.MediaType & MediaType.Video) == MediaType.Video) ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden;

                this.timerCall.Start();
                if (this.avHistoryEvent != null)
                {
                    if (this.avHistoryEvent.Status == HistoryEvent.StatusType.Missed)
                    {
                        this.avHistoryEvent.Status = HistoryEvent.StatusType.Incoming;
                    }
                    this.avHistoryEvent.StartTime = DateTime.Now;
                    this.avHistoryEvent.EndTime   = this.avHistoryEvent.StartTime;
                }

                if (this.labelQuality.Visibility == System.Windows.Visibility.Visible)
                {
                    this.labelQuality.Content = "Quality: 100%";
                    this.timerQuality.Start();
                }

                break;
            }

            case InviteEventTypes.DISCONNECTED:
            case InviteEventTypes.TERMWAIT:
            {
                if (runningAppsWindow != null)
                {
                    runningAppsWindow.Close();
                    runningAppsWindow = null;
                }

                if (this.qosWindow != null)
                {
                    this.qosWindow.Close();
                    this.qosWindow = null;
                }

                this.labelInfo.Content = e.Type == InviteEventTypes.TERMWAIT ? Strings.Text_CallTerminated : e.Phrase;

                this.timerCall.Stop();
                this.timerQuality.Stop();
                this.soundService.StopRingBackTone();
                this.soundService.StopRingTone();

                if (this.avHistoryEvent != null)
                {
                    lock (this.avHistoryEvent)
                    {
                        this.avHistoryEvent.EndTime = DateTime.Now;
                        this.historyService.AddEvent(this.avHistoryEvent);
                        this.avHistoryEvent = null;
                    }
                }

                this.videoDisplayLocal.Visibility          = System.Windows.Visibility.Hidden;
                this.videoDisplayRemote.Visibility         = System.Windows.Visibility.Hidden;
                this.videoDisplayScrenCastLocal.Visibility = System.Windows.Visibility.Hidden;
                this.labelQuality.Visibility = System.Windows.Visibility.Hidden;
                this.AVSession.PreDispose();
                this.AVSession = null;
                break;
            }

            case InviteEventTypes.LOCAL_HOLD_OK:
            {
                if (this.isTransfering)
                {
                    this.isTransfering = false;
                    this.AVSession.TransferCall(this.transferUri);
                }
                this.labelInfo.Content = Strings.Text_CallPlacedOnHold;
                this.IsHeld            = true;
                break;
            }

            case InviteEventTypes.LOCAL_HOLD_NOK:
            {
                this.isTransfering     = false;
                this.labelInfo.Content = Strings.Text_FailedToPlaceRemotePartyOnHold;
                break;
            }

            case InviteEventTypes.LOCAL_RESUME_OK:
            {
                this.isTransfering     = false;
                this.labelInfo.Content = Strings.Text_CallTakenOffHold;
                this.IsHeld            = false;
                break;
            }

            case InviteEventTypes.LOCAL_RESUME_NOK:
            {
                this.isTransfering     = false;
                this.labelInfo.Content = Strings.Text_FailedToUnholdCall;
                break;
            }

            case InviteEventTypes.REMOTE_HOLD:
            {
                this.labelInfo.Content = Strings.Text_PlacedOnHoldByRemoteParty;
                break;
            }

            case InviteEventTypes.REMOTE_RESUME:
            {
                this.labelInfo.Content = Strings.Text_TakenOffHoldByRemoteParty;
                break;
            }


            case InviteEventTypes.LOCAL_TRANSFER_TRYING:
            {
                this.labelInfo.Content = String.Format("{0}: {1}", Strings.Text_CallTransfer, Strings.Text_Initiated);
                break;
            }

            case InviteEventTypes.LOCAL_TRANSFER_FAILED:
            {
                this.labelInfo.Content = String.Format("{0}: {1}", Strings.Text_CallTransfer, Strings.Text_Failed);
                break;
            }

            case InviteEventTypes.LOCAL_TRANSFER_ACCEPTED:
            {
                this.labelInfo.Content = String.Format("{0}: {1}", Strings.Text_CallTransfer, Strings.Text_Accepted);
                break;
            }

            case InviteEventTypes.LOCAL_TRANSFER_COMPLETED:
            {
                this.labelInfo.Content = String.Format("{0}: {1}", Strings.Text_CallTransfer, Strings.Text_Completed);
                break;
            }

            case InviteEventTypes.LOCAL_TRANSFER_NOTIFY:
            case InviteEventTypes.REMOTE_TRANSFER_NOTIFY:
            {
                short?code = e.GetExtra(InviteEventArgs.EXTRA_SIP_CODE) as short?;
                this.labelInfo.Content = String.Format("{0}: {1} {2}", Strings.Text_CallTransfer, code.HasValue ? code.Value : -1, e.Phrase);
                if (code.HasValue)
                {
                    if (code.Value >= 300 && this.IsHeld)
                    {
                        this.AVSession.ResumeCall();
                    }
                }
                break;
            }

            case InviteEventTypes.REMOTE_TRANSFER_REQUESTED:
            {
                new Thread((System.Threading.ParameterizedThreadStart) delegate(object _e)
                    {
                        this.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
                        {
                            InviteEventArgs args = _e as InviteEventArgs;
                            if (args != null)
                            {
                                String referToUri  = args.GetExtra(InviteEventArgs.EXTRA_REFERTO_URI) as String;
                                String referToName = UriUtils.GetDisplayName(referToUri);
                                DialogResult ret   = MessageBox.Show(String.Format("Call Transfer to {0} requested. Do you accept?", referToName), "Call Transfer Request", MessageBoxButtons.YesNo);
                                if (this.AVSession != null)
                                {
                                    if (ret == System.Windows.Forms.DialogResult.Yes)
                                    {
                                        this.AVSession.AcceptCallTransfer();
                                    }
                                    else
                                    {
                                        this.AVSession.RejectCallTransfer();
                                    }
                                }
                            }
                        });
                    })
                .Start(e);
                break;
            }

            case InviteEventTypes.REMOTE_TRANSFER_INPROGESS:
            {
                this.AVTransfSession = e.GetExtra(InviteEventArgs.EXTRA_SESSION) as MyAVSession;
                break;
            }

            case InviteEventTypes.REMOTE_TRANSFER_FAILED:
            {
                this.AVTransfSession = null;
                break;
            }

            case InviteEventTypes.REMOTE_TRANSFER_COMPLETED:
            {
                if (this.AVTransfSession != null)
                {
                    this.AVSession       = this.AVTransfSession;
                    this.AVTransfSession = null;
                    this.InitializeView();
                    this.UpdateControls();
                }
                break;
            }
            }
        }
コード例 #10
0
        private void sipService_onInviteEvent(object sender, InviteEventArgs e)
        {
            if (this.@event == null || [email protected] == null)
            {
                return;
            }

            if (e.SessionId != [email protected])
            {
                return;
            }

            if (this.Dispatcher.Thread != System.Threading.Thread.CurrentThread)
            {
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                            new EventHandler <InviteEventArgs>(this.sipService_onInviteEvent), sender, new object[] { e });
                return;
            }

            switch (e.Type)
            {
            case InviteEventTypes.CONNECTED:
            {
                if (this.imageIcon.Source == null && File.Exists([email protected]))
                {
                    using (System.Drawing.Icon icon = System.Drawing.Icon.ExtractAssociatedIcon([email protected]))
                    {
                        this.imageIcon.Source = MyImageConverter.FromIcon(icon);
                    }
                }
                this.buttonAccept.Visibility  = Visibility.Collapsed;
                this.buttonDecline.Visibility = Visibility.Visible;
                this.buttonDecline.Content    = "abort";
                break;
            }

            case InviteEventTypes.DISCONNECTED:
            {
                if (!this.done)
                {
                    this.buttonAccept.Visibility  = Visibility.Collapsed;
                    this.buttonDecline.Visibility = Visibility.Collapsed;
                    this.progressBar.Visibility   = Visibility.Collapsed;

                    this.labelDescription.Content = String.Format("File transfer Failed ({0})", e.Phrase);
                    this.gradientStop.Color       = Colors.Red;

                    this.imageIcon.Cursor = Cursors.No;
                }
                else
                {
                    this.imageIcon.Cursor = Cursors.Hand;
                    this.imageIcon.Tag    = [email protected];
                }

                this.sipService.onInviteEvent -= this.sipService_onInviteEvent;
                break;
            }

            default:
                break;
            }
        }
コード例 #11
0
 public void PluginsOnInvite(object sender, InviteEventArgs e)
 {
     OnInvite(this, e);
 }
コード例 #12
0
            /// <summary>
            /// Call (MSRP, Audio, Video, T.38, ...) events
            /// </summary>
            /// <param name="e"></param>
            /// <returns></returns>
            public override int OnInviteEvent(InviteEvent e)
            {
                tsip_invite_event_type_t type = e.getType();
                short         code            = e.getCode();
                String        phrase          = e.getPhrase();
                InviteSession session         = e.getSession();

                switch (type)
                {
                case tsip_invite_event_type_t.tsip_i_newcall:
                    if (session != null)     /* As we are not the owner, then the session MUST be null */
                    {
                        LOG.Error("Invalid incoming session");
                        session.hangup();     // To avoid another callback event
                        return(-1);
                    }

                    SipMessage message = e.getSipMessage();
                    if (message == null)
                    {
                        LOG.Error("Invalid message");
                        return(-1);
                    }
                    twrap_media_type_t sessionType = e.getMediaType();

                    switch (sessionType)
                    {
                    case twrap_media_type_t.twrap_media_msrp:
                    {
                        if ((session = e.takeMsrpSessionOwnership()) == null)
                        {
                            LOG.Error("Failed to take MSRP session ownership");
                            return(-1);
                        }

                        MyMsrpSession msrpSession = MyMsrpSession.TakeIncomingSession(this.sipService.SipStack, session as MsrpSession, message);
                        if (msrpSession == null)
                        {
                            LOG.Error("Failed to create new session");
                            session.hangup();
                            session.Dispose();
                            return(0);
                        }
                        msrpSession.State = MyInviteSession.InviteState.INCOMING;

                        InviteEventArgs eargs = new InviteEventArgs(msrpSession.Id, InviteEventTypes.INCOMING, phrase);
                        eargs.AddExtra(InviteEventArgs.EXTRA_SESSION, msrpSession);
                        EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, eargs);
                        break;
                    }

                    case twrap_media_type_t.twrap_media_audio:
                    case twrap_media_type_t.twrap_media_audiovideo:
                    case twrap_media_type_t.twrap_media_video:
                    {
                        if ((session = e.takeCallSessionOwnership()) == null)
                        {
                            LOG.Error("Failed to take audio/video session ownership");
                            return(-1);
                        }
                        MyAVSession avSession = MyAVSession.TakeIncomingSession(this.sipService.SipStack, session as CallSession, sessionType, message);
                        avSession.State = MyInviteSession.InviteState.INCOMING;

                        InviteEventArgs eargs = new InviteEventArgs(avSession.Id, InviteEventTypes.INCOMING, phrase);
                        eargs.AddExtra(InviteEventArgs.EXTRA_SESSION, avSession);
                        EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, eargs);
                        break;
                    }

                    default:
                        LOG.Error("Invalid media type");
                        return(0);
                    }
                    break;

                case tsip_invite_event_type_t.tsip_ao_request:
                    if (code == 180 && session != null)
                    {
                        EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                           new InviteEventArgs(session.getId(), InviteEventTypes.RINGING, phrase));
                    }
                    break;

                case tsip_invite_event_type_t.tsip_i_request:
                case tsip_invite_event_type_t.tsip_o_ect_ok:
                case tsip_invite_event_type_t.tsip_o_ect_nok:
                case tsip_invite_event_type_t.tsip_i_ect:
                {
                    break;
                }

                case tsip_invite_event_type_t.tsip_m_early_media:
                {
                    EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                       new InviteEventArgs(session.getId(), InviteEventTypes.EARLY_MEDIA, phrase));
                    break;
                }

                case tsip_invite_event_type_t.tsip_m_local_hold_ok:
                {
                    EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                       new InviteEventArgs(session.getId(), InviteEventTypes.LOCAL_HOLD_OK, phrase));
                    break;
                }

                case tsip_invite_event_type_t.tsip_m_local_hold_nok:
                {
                    EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                       new InviteEventArgs(session.getId(), InviteEventTypes.LOCAL_HOLD_NOK, phrase));
                    break;
                }

                case tsip_invite_event_type_t.tsip_m_local_resume_ok:
                {
                    EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                       new InviteEventArgs(session.getId(), InviteEventTypes.LOCAL_RESUME_OK, phrase));
                    break;
                }

                case tsip_invite_event_type_t.tsip_m_local_resume_nok:
                {
                    EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                       new InviteEventArgs(session.getId(), InviteEventTypes.LOCAL_RESUME_NOK, phrase));
                    break;
                }

                case tsip_invite_event_type_t.tsip_m_remote_hold:
                {
                    EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                       new InviteEventArgs(session.getId(), InviteEventTypes.REMOTE_HOLD, phrase));
                    break;
                }

                case tsip_invite_event_type_t.tsip_m_remote_resume:
                {
                    EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService,
                                                                       new InviteEventArgs(session.getId(), InviteEventTypes.REMOTE_RESUME, phrase));
                    break;
                }
                }


                return(0);
            }
コード例 #13
0
            /// <summary>
            /// Dialog events (Common to all)
            /// </summary>
            /// <param name="e"></param>
            /// <returns></returns>
            public override int OnDialogEvent(DialogEvent e)
            {
                String     phrase  = e.getPhrase();
                short      code    = e.getCode();
                SipSession session = e.getBaseSession();

                if (session == null)
                {
                    return(0);
                }

                uint         sessionId = session.getId();
                MySipSession mySession = null;

                SipService.LOG.Info(String.Format("OnDialogEvent ({0})", phrase));

                if (code == tinyWRAP.tsip_event_code_dialog_connecting)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        EventHandlerTrigger.TriggerEvent <RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                                                                                 new RegistrationEventArgs(RegistrationEventTypes.REGISTRATION_INPROGRESS, code, phrase));
                    }
                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.INPROGRESS;
                        InviteEventArgs eargs = new InviteEventArgs(sessionId, InviteEventTypes.INPROGRESS, phrase);
                        eargs.AddExtra(InviteEventArgs.EXTRA_SESSION, mySession);
                        EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, eargs);
                    }

                    // Subscription

                    // Publication
                }


                else if (code == tinyWRAP.tsip_event_code_dialog_connected)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        this.sipService.regSession.IsConnected = true;
                        // Update default identity (vs barred)
                        String _defaultIdentity = this.sipService.SipStack.getPreferredIdentity();
                        if (!String.IsNullOrEmpty(_defaultIdentity))
                        {
                            this.sipService.defaultIdentity = _defaultIdentity;
                        }
                        // Do PostRegistrationOp() in new thread to avoid blocking callbacks
                        new Thread(new ThreadStart(delegate
                        {
                            this.sipService.DoPostRegistrationOp();
                        }))
                        .Start();
                        EventHandlerTrigger.TriggerEvent <RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                                                                                 new RegistrationEventArgs(RegistrationEventTypes.REGISTRATION_OK, code, phrase));
                    }

                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.INCALL;
                        mySession.IsConnected = true;
                        EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, new InviteEventArgs(sessionId, InviteEventTypes.CONNECTED, phrase));
                    }

                    // Subscription
                    else if ((mySession = this.sipService.subPresence.FirstOrDefault(x => x.Id == sessionId)) != null)
                    {
                        mySession.IsConnected = true;
                    }

                    // Publication
                    else if (this.sipService.pubPres != null && this.sipService.pubPres.Id == sessionId)
                    {
                        this.sipService.pubPres.IsConnected = true;
                    }
                }


                else if (code == tinyWRAP.tsip_event_code_dialog_terminating)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        EventHandlerTrigger.TriggerEvent <RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                                                                                 new RegistrationEventArgs(RegistrationEventTypes.UNREGISTRATION_INPROGRESS, code, phrase));
                    }

                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.TERMINATING;
                        EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, new InviteEventArgs(sessionId, InviteEventTypes.TERMWAIT, phrase));
                    }

                    // Subscription

                    // Publication
                }


                else if (code == tinyWRAP.tsip_event_code_dialog_terminated)
                {
                    // Registration
                    if (this.sipService.regSession != null && this.sipService.regSession.Id == sessionId)
                    {
                        this.sipService.regSession.IsConnected = false;
                        // To PostRegistration() in new thread
                        EventHandlerTrigger.TriggerEvent <RegistrationEventArgs>(this.sipService.onRegistrationEvent, this.sipService,
                                                                                 new RegistrationEventArgs(RegistrationEventTypes.UNREGISTRATION_OK, code, phrase));
                        /* Stop the stack (as we are already in the stack-thread, then do it in a new thread) */
                        new Thread(new ThreadStart(delegate
                        {
                            if (this.sipService.sipStack.State == MySipStack.STACK_STATE.STARTED)
                            {
                                this.sipService.sipStack.stop();
                            }
                        })).Start();
                    }

                    // Audio/Video/MSRP
                    else if (((mySession = MyAVSession.GetSession(sessionId)) != null) || ((mySession = MyMsrpSession.GetSession(sessionId)) != null))
                    {
                        mySession.IsConnected = false;
                        (mySession as MyInviteSession).State = MyInviteSession.InviteState.TERMINATED;
                        EventHandlerTrigger.TriggerEvent <InviteEventArgs>(this.sipService.onInviteEvent, this.sipService, new InviteEventArgs(sessionId, InviteEventTypes.DISCONNECTED, phrase));
                    }

                    // Subscription
                    else if ((mySession = this.sipService.subPresence.FirstOrDefault(x => x.Id == sessionId)) != null)
                    {
                        mySession.IsConnected = false;
                        this.sipService.subPresence.Remove(mySession as MySubscriptionSession);
                    }

                    // Publication
                    else if (this.sipService.pubPres != null && this.sipService.pubPres.Id == sessionId)
                    {
                        this.sipService.pubPres.IsConnected = false;
                        if (this.sipService.hyperAvailabilityTimer != null)
                        {
                            if (this.sipService.hyperAvailabilityTimer.Enabled)
                            {
                                this.sipService.hyperAvailabilityTimer.Stop();
                            }
                            this.sipService.hyperAvailabilityTimer = null;
                        }
                    }
                }

                return(0);
            }
コード例 #14
0
 protected virtual void HandleInvite(object sender, InviteEventArgs e)
 {
     OnInvited(new UserInvitedToChannelEventArgs(e));
 }
コード例 #15
0
        private void sipService_onInviteEvent(object sender, InviteEventArgs e)
        {
            if (this.AVSession == null || this.AVSession.Id != e.SessionId)
            {
                /* Messaging */
                if (e.Type == InviteEventTypes.DISCONNECTED)
                {
                    if (this.historyDataSource.Any(x => x.SipSessionId == e.SessionId))
                    {
                        this.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
                        {
                            HistoryEvent @event = this.historyDataSource.FirstOrDefault(x => x.SipSessionId == e.SessionId);
                            if (@event != null)
                            {
                                this.historyService.AddEvent(@event);
                            }
                        }, null);
                    }
                    else if (this.ChatSession != null && this.ChatSession.Id == e.SessionId)
                    {
                        this.Dispatcher.Invoke((System.Threading.ThreadStart) delegate
                        {
                            this.ChatSession = null;
                        });
                    }
                }
                return;
            }

            /* Audio/Video */

            if (this.Dispatcher.Thread != Thread.CurrentThread)
            {
                this.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal,
                                            new EventHandler <InviteEventArgs>(this.sipService_onInviteEvent), sender, new object[] { e });
                return;
            }

            this.UpdateControls();

            switch (e.Type)
            {
            case InviteEventTypes.INCOMING:
                this.labelInfo.Content     = String.Format("Incoming call from {0}", this.AVSession.RemotePartyDisplayName);
                this.avHistoryEvent        = new HistoryAVCallEvent(this.AVSession.MediaType != BogheCore.MediaType.Audio, this.AVSession.RemotePartyUri);
                this.avHistoryEvent.Status = HistoryEvent.StatusType.Missed;
                break;

            case InviteEventTypes.INPROGRESS:
                // History Event
                this.labelInfo.Content = "Call In Progress...";
                bool isVideo = (this.AVSession.MediaType == MediaType.AudioVideo || this.AVSession.MediaType == MediaType.Video);
                this.avHistoryEvent        = new HistoryAVCallEvent(isVideo, this.AVSession.RemotePartyUri);
                this.avHistoryEvent.Status = HistoryEvent.StatusType.Outgoing;
                // Video Displays
                if (isVideo)
                {
                    this.AttachDisplays();
                }

                break;

            case InviteEventTypes.RINGING:
                this.labelInfo.Content = "Ringing";
                this.soundService.PlayRingBackTone();
                break;

            case InviteEventTypes.EARLY_MEDIA:
                this.labelInfo.Content = "Early Media Started";
                this.soundService.StopRingBackTone();
                this.soundService.StopRingTone();
                break;

            case InviteEventTypes.CONNECTED:
                this.labelInfo.Content = "In Call";
                this.soundService.StopRingBackTone();
                this.soundService.StopRingTone();

                this.videoDisplayLocal.Visibility  = System.Windows.Visibility.Visible;
                this.videoDisplayRemote.Visibility = System.Windows.Visibility.Visible;

                this.timerCall.Start();
                if (this.avHistoryEvent != null)
                {
                    if (this.avHistoryEvent.Status == HistoryEvent.StatusType.Missed)
                    {
                        this.avHistoryEvent.Status = HistoryEvent.StatusType.Incoming;
                    }
                    this.avHistoryEvent.StartTime = DateTime.Now;
                    this.avHistoryEvent.EndTime   = this.avHistoryEvent.StartTime;
                }

                break;

            case InviteEventTypes.DISCONNECTED:
            case InviteEventTypes.TERMWAIT:
                this.labelInfo.Content = e.Type == InviteEventTypes.TERMWAIT ? "Call Terminated" : e.Phrase;
                this.timerCall.Stop();
                this.soundService.StopRingBackTone();
                this.soundService.StopRingTone();

                if (this.avHistoryEvent != null)
                {
                    lock (this.avHistoryEvent)
                    {
                        this.avHistoryEvent.EndTime = DateTime.Now;
                        this.historyService.AddEvent(this.avHistoryEvent);
                        this.avHistoryEvent = null;
                    }
                }

                //--this.videoDisplayLocal.Visibility = System.Windows.Visibility.Hidden;
                //--this.videoDisplayRemote.Visibility = System.Windows.Visibility.Hidden;
                this.AVSession = null;
                break;

            case InviteEventTypes.LOCAL_HOLD_OK:
                this.labelInfo.Content = "Call placed on hold";
                this.IsHeld            = true;
                break;

            case InviteEventTypes.LOCAL_HOLD_NOK:
                this.labelInfo.Content = "Failed to place remote party on hold";
                break;

            case InviteEventTypes.LOCAL_RESUME_OK:
                this.labelInfo.Content = "Call taken off hold";
                this.IsHeld            = false;
                break;

            case InviteEventTypes.LOCAL_RESUME_NOK:
                this.labelInfo.Content = "Failed to unhold call";
                break;

            case InviteEventTypes.REMOTE_HOLD:
                this.labelInfo.Content = "Placed on hold by remote party";
                break;

            case InviteEventTypes.REMOTE_RESUME:
                this.labelInfo.Content = "Taken off hold by remote party";
                break;
            }
        }