Пример #1
1
 public void HandleHangupCompleteEvent(switch_event evt, String uuid)
 {
     CALL_STATE = CALL_STATE.RELEASED;
 }
Пример #2
0
        public static void HandleHangupCompleteEvent(FSEvent evt, String uuid)
        {
            Utils.DebugEventDump(evt);
            Call call = (from c in calls where c.call_ended == false && (c.leg_a_uuid == uuid || c.leg_b_uuid == uuid) select c).SingleOrDefault();

            if (call == null || call.call_ended)
            {
                return;
            }

            CALL_STATE new_state = CALL_STATE.None;


            if (call.state != CALL_STATE.Answered && call.state != CALL_STATE.Missed && call.state != CALL_STATE.Hold)
            {
                if (String.IsNullOrEmpty(call.note))
                {
                    call.note = evt.get_header("variable_sip_hangup_phrase");
                }
                if (!call.is_outgoing && call.state == CALL_STATE.Ringing)
                {
                    new_state = CALL_STATE.Missed;
                }
                else
                {
                    new_state = CALL_STATE.Failed;
                }
            }
            else if (call.state == CALL_STATE.Answered || call.state == CALL_STATE.Hold)
            {
                new_state = CALL_STATE.Ended;
            }

            if (new_state == CALL_STATE.None)
            {
                throw new Exception("Not sure what happened call was at state...: " + call.state);
            }
            Call new_active_call;

            if (Call.active_call != call)
            {
                new_active_call = Call.active_call;
            }
            else
            {
                new_active_call = (from c in calls where c.state == CALL_STATE.Ringing && c.is_outgoing == false && c != call select c).FirstOrDefault();
            }
            call.UpdateCallState(new_state, new_active_call);
        }
Пример #3
0
        private void UpdateCallState(CALL_STATE new_state, Call new_active_call)
        {
            bool actually_make_active  = active_call != new_active_call;
            bool actually_update_state = state != new_state;
            bool set_call_ended        = new_state != CALL_STATE.Answered && new_state != CALL_STATE.Ringing && new_state != CALL_STATE.Hold && new_state != CALL_STATE.Hold_Ringing && call_ended == false;
            ActiveCallChangedArgs args = null;

            if (actually_update_state)
            {
                _state = new_state;
            }
            if (actually_make_active)
            {
                args = new ActiveCallChangedArgs {
                    new_active_call = new_active_call, old_active_call = active_call
                };
                active_call = new_active_call;
            }
            if (set_call_ended)
            {
                call_ended = true;
                _end_time  = DateTime.Now;
            }

            if (args != null)
            {
                ActiveCallChanged(null, args);
            }

            if (actually_update_state)
            {
                RaisePropertyChanged("state");
            }
            if (set_call_ended)
            {
                RaisePropertyChanged("call_ended");
                RaisePropertyChanged("end_time");
            }
        }
Пример #4
0
        private void UpdateCallState(CALL_STATE new_state, Call new_active_call)
        {
            bool actually_make_active = active_call != new_active_call;
            bool actually_update_state = state != new_state;
            bool set_call_ended = new_state != CALL_STATE.Answered && new_state != CALL_STATE.Ringing && new_state != CALL_STATE.Hold && new_state != CALL_STATE.Hold_Ringing && call_ended == false;
            ActiveCallChangedArgs args = null;

            if (actually_update_state)
                _state = new_state;
            if (actually_make_active) {
                args = new ActiveCallChangedArgs { new_active_call = new_active_call, old_active_call = active_call };
                active_call = new_active_call;
            }
            if (set_call_ended) {
                call_ended = true;
                _end_time = DateTime.Now;
            }

            if (args != null)
                ActiveCallChanged(null, args);

            if (actually_update_state)
                RaisePropertyChanged("state");
            if (set_call_ended) {
                RaisePropertyChanged("call_ended");
                RaisePropertyChanged("end_time");
            }
        }
Пример #5
0
 private void UpdateCallState(CALL_STATE new_state)
 {
     UpdateCallState(new_state, active_call);
 }
Пример #6
0
 private void UpdateCallState(CALL_STATE new_state)
 {
     UpdateCallState(new_state, active_call);
 }
Пример #7
0
 private void HandleCustomEvent(switch_event evt, string uuid)
 {
     if (evt.subclass_name == "portaudio::ringing")
     {
         CALL_STATE = CALL_STATE.INCOMING;
     }
     else if (evt.subclass_name == "portaudio::makecall")
     {
         CALL_STATE = CALL_STATE.ALERTING;
     }
     else if (evt.subclass_name == "portaudio::callheld" || evt.subclass_name == "portaudio::callresumed")
     {
         CALL_STATE = CALL_STATE.HOLDING;
     }
 }
Пример #8
0
 private void HandleChannelAnswerEvent(switch_event evt, String uuid)
 {
     if (CALL_STATE == CALL_STATE.Answered)
         return;
     CALL_STATE = CALL_STATE.ACTIVE;
 }
Пример #9
0
        private void actual_event_handler(switch_event switchEvent)
        {
            if (CALL_STATE == CALL_STATE.NULL)
                ACCOUNT_STATE = ACCOUNT_STATE.REGISTERED;
            if (switchEvent.event_id == switch_event_types_t.SWITCH_EVENT_MODULE_LOAD)
            {
                CALL_STATE = CALL_STATE.NULL;
                ACCOUNT_STATE = ACCOUNT_STATE.REGISTERING;
                return;
            }

            String uuid = "";//switchEvent.get_header("Unique-ID");
            switch (switchEvent.event_id)
            {
                case switch_event_types_t.SWITCH_EVENT_CHANNEL_CREATE:
                    HandleChannelCreateEvent(switchEvent, uuid);
                    break;

                case switch_event_types_t.SWITCH_EVENT_CHANNEL_OUTGOING:
                    HandleOutgoingEvent(switchEvent, uuid);
                    break;

                case switch_event_types_t.SWITCH_EVENT_CHANNEL_HANGUP_COMPLETE:
                    HandleHangupCompleteEvent(switchEvent, uuid);
                    break;

                case switch_event_types_t.SWITCH_EVENT_CHANNEL_ANSWER:
                    HandleChannelAnswerEvent(switchEvent, uuid);
                    break;

                case switch_event_types_t.SWITCH_EVENT_CUSTOM:
                    HandleCustomEvent(switchEvent, uuid);
                    break;

                case switch_event_types_t.SWITCH_EVENT_CHANNEL_DESTROY:

                    //channels.Remove(uuid);
                    break;

                case switch_event_types_t.SWITCH_EVENT_DTMF:
                    HandleDTMFEvent(switchEvent, uuid);
                    break;

                default:

                    break;
            }
        }
Пример #10
0
 private void SetIconByCallState(CALL_STATE state)
 {
     switch (state)
     {
         case CALL_STATE.ACTIVE:Icon = Resources.Circle_Red;
             break;
         case CALL_STATE.ALERTING:Icon = Resources.Circle_Orange;
             break;
         case CALL_STATE.CONNECTING:Icon = Resources.Circle_Yellow;
             break;
         case CALL_STATE.HOLDING:Icon = Resources.Circle_Blue;
             break;
         case CALL_STATE.IDLE: SetIconByAccountState(Agent.ACCOUNT_STATE);
             break;
         case CALL_STATE.INCOMING:Icon = Resources.Circle_Orange;
             break;
         case CALL_STATE.NULL: SetIconByAccountState(Agent.ACCOUNT_STATE);
             break;
         case CALL_STATE.RELEASED:
             Icon = Resources.Circle_Yellow;
             SetIconByAccountState(Agent.ACCOUNT_STATE);
             break;
         case CALL_STATE.TERMINATED:Icon = Resources.Circle_Yellow;
             break;
     }
     if (Agent.CALL_STATE != CALL_STATE.NULL)
     notifyIcon.ShowBalloonTip(2, state.ToString(), "dfs", ToolTipIcon.Info);
 }
Пример #11
0
 private void Agent_OnCallStateChanged(CALL_STATE state)
 {
     SetIconByCallState(state);
 }