Exemple #1
0
        private void OnSwitchEvent(EventBase theEvent)
        {
            EventChannelState e = theEvent as EventChannelState;

            if (e != null)
            {
                EventChannelState channelEvent = theEvent as EventChannelState;
                if (channelEvent == null)
                {
                    return;
                }

                //OnSwitchEvents(theEvent);

                ListViewItem item;
                item     = lvAll.Items.Add(channelEvent.ChannelInfo.Address);
                item.Tag = channelEvent;
                item.SubItems.Add(channelEvent.Originator.UserName);
                item.SubItems.Add(channelEvent.UniqueId);
                item.SubItems.Add(channelEvent.Caller.UniqueId);
                if (channelEvent.Name == "CHANNEL_STATE")
                {
                    item.SubItems.Add(e.ChannelInfo.State.ToString());
                }
                else
                {
                    item.SubItems.Add(e.Name);
                }

                if (e.GetType() == typeof(EventCodec) || theEvent.GetType() == typeof(EventChannelExecute) ||
                    e.Originator.DestinationNumber == string.Empty)
                {
                    item.ForeColor = Color.Gray;
                }
            }
            log.Text = theEvent.Name;
        }
Exemple #2
0
        public void OnSwitchEvents2(EventBase theEvent)
        {
            ChannelEvent      evt          = theEvent as ChannelEvent;
            EventChannelState channelState = theEvent as EventChannelState;

            if (channelState != null)
            {
                Debug.WriteLine("ChannelState: " + channelState.ChannelInfo.State + " " + channelState.Caller.UserName +
                                " " + channelState.Caller.DestinationNumber);
            }
            else if (evt != null && evt.ChannelInfo != null)
            {
                Debug.WriteLine("ChannelEvent: " + evt.Name + " " + evt.ChannelInfo.Address);
            }
            if (evt != null)
            {
                // CHANNEL_ANSWER, No originator = new outgoing call.
                // ChannelName = the one who makes the call
                if (evt is EventChannelAnswer)
                {
                    EventChannelAnswer e = (EventChannelAnswer)evt;
                    if (e.Originator.CallerIdName != string.Empty)
                    {
                        Debug.WriteLine("Skipping emoty ChannelAnswer");
                        return; // We do only want empty ones.
                    }

                    if (!IsExternalNumber(evt.ChannelInfo.Address))
                    {
                        Debug.WriteLine("triggering CallState.Alerting");
                        TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Alerting,
                                         e.Caller.DestinationNumber);
                    }
                }

                // CHANNEL_OUTGOING, Event for Alerting/Offering
                // Originator = the one calling
                // ChannelName = the one getting called.
                else if (evt is EventChannelOutgoing)
                {
                    EventChannelOutgoing e = (EventChannelOutgoing)evt;
                    if (!IsExternalNumber(evt.ChannelInfo.Address))
                    {
                        Debug.WriteLine("triggering CallState.Offering");
                        TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Offering, e.Originator.UserName);
                    }
                    if (!IsExternalNumber(e.Originator.UserName))
                    {
                        Debug.WriteLine("triggering CallState.Alerting");
                        TriggerCallState(e.Originator.UserName, e.Originator.UniqueId, CallState.Alerting,
                                         e.ChannelInfo.Address);
                    }
                }

                else if (evt is EventChannelBridge)
                {
                    EventChannelBridge e = (EventChannelBridge)evt;
                    if (!IsExternalNumber(evt.ChannelInfo.Address))
                    {
                        Debug.WriteLine("triggering CallState.Connected");
                        TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Connected,
                                         e.Caller.DestinationNumber);
                    }

                    // Trigger destination
                    if (!IsExternalNumber(e.Caller.DestinationNumber) && e.Originator.ChannelName != string.Empty)
                    {
                        Debug.WriteLine("triggering CallState.Connected");
                        TriggerCallState(ChannelDestination(e.Originator.ChannelName), e.UniqueId, CallState.Connected,
                                         e.ChannelInfo.Address);
                    }
                }

                else if (evt is EventChannelDestroy)
                {
                    EventChannelDestroy e = (EventChannelDestroy)evt;
                    Debug.WriteLine("triggering CallState.Disconnected");
                    TriggerCallState(evt.ChannelInfo.Address, e.UniqueId, CallState.Disconnected,
                                     e.Originator.DestinationNumber);
                }
            }
        }