示例#1
0
        protected BasicChannel(ChannelEvent eventMessage, EventSocket eventSocket)
        {
            Log = LogProvider.GetLogger(GetType());

            UUID             = eventMessage.UUID;
            lastEvent        = eventMessage;
            this.eventSocket = eventSocket;

            Variables = new ChannelVariables(this);

            Disposables.Add(
                eventSocket.ChannelEvents
                .Where(x => x.UUID == UUID)
                .Subscribe(
                    e =>
            {
                lastEvent = e;

                if (e.EventName == EventName.ChannelAnswer)
                {
                    Log.Info(() => "Channel [{0}] Answered".Fmt(UUID));
                }

                if (e.EventName == EventName.ChannelHangupComplete)
                {
                    Log.Info(() => "Channel [{0}] Hangup Detected [{1}]".Fmt(UUID, e.HangupCause));

                    try
                    {
                        HangupCallBack(e);
                    }
                    catch (Exception ex)
                    {
                        Log.ErrorException("Channel [{0}] error calling hangup callback".Fmt(UUID), ex);
                    }

                    Dispose();
                }
            }));
        }
示例#2
0
        protected BasicChannel(ChannelEvent eventMessage, EventSocket eventSocket)
        {
            Log = Logger.Get<BasicChannel>();

            Uuid = eventMessage.UUID;
            lastEvent = eventMessage;
            this.eventSocket = eventSocket;

            Variables = new ChannelVariables(this);

            Disposables.Add(
                eventSocket.ChannelEvents
                           .Where(x => x.UUID == Uuid)
                           .Subscribe(
                               e =>
                                   {
                                       lastEvent = e;

                                       if (e.EventName == EventName.ChannelAnswer)
                                       {
                                           Log.LogInformation("Channel [{0}] Answered".Fmt(Uuid));
                                       }

                                       if (e.EventName == EventName.ChannelHangupComplete)
                                       {
                                           Log.LogInformation("Channel [{0}] Hangup Detected [{1}]".Fmt(Uuid, e.HangupCause));

                                           try
                                           {
                                               HangupCallBack(e);
                                           }
                                           catch (Exception ex)
                                           {
                                               Log.LogError(ex, "Channel [{0}] error calling hangup callback".Fmt(Uuid));
                                           }
                                           
                                           Dispose();
                                       }
                                   }));
        }