Esempio n. 1
0
        void VoipInfoReceived(ISoundstructureItem item, SoundstructureVoipInfoReceivedEventArgs args)
        {
            if (item == this.VoipOutChannel)
            {
                List <string> elements = SoundstructureSocket.ElementsFromString(args.Info);
                if (elements.Count > 1)
                {
                    uint lineNumber = uint.Parse(elements[0]);
                    if (lineNumber == this.Number)
                    {
                        try
                        {
                            switch (args.Command)
                            {
                            case "voip_line_state":
                                try
                                {
                                    this.State = (VoipLineState)Enum.Parse(typeof(VoipLineState), elements[1], true);
                                    if (StateChanged != null)
                                    {
                                        StateChanged(this, this.State);
                                    }
                                }
                                catch (Exception e)
                                {
                                    ErrorLog.Error("Could not parse VoipLineState \"{2}\" for Line {0}, {1}",
                                                   lineNumber, e.Message, elements[1]);
                                }
                                break;

                            case "voip_line_label":
                                this.Label = elements[1];
                                break;

                            case "voip_call_appearance_line":
                                this.CallAppearance = uint.Parse(elements[1]);
                                break;

                            case "voip_call_appearance_state":
                                try
                                {
                                    VoipCallAppearanceState state = (VoipCallAppearanceState)Enum.Parse(typeof(VoipCallAppearanceState), elements[1], true);
                                    if (this.CallAppearanceState != state)
                                    {
                                        this.CallAppearanceState = state;
                                        if (CallAppearanceState == VoipCallAppearanceState.Connected)
                                        {
                                            _CallConnectedTime = DateTime.Now;
                                        }
                                    }
                                    try
                                    {
                                        if (CallAppearanceStateChanged != null)
                                        {
                                            CallAppearanceStateChanged(this, new VoipLineCallAppearanceStateEventArgs(this.CallAppearance, this.CallAppearanceState));
                                        }
                                    }
                                    catch (Exception e)
                                    {
                                        ErrorLog.Exception(string.Format("Error calling event {0}.CallAppearanceStateChanged", this.GetType().Name), e);
                                    }
                                }
                                catch (Exception e)
                                {
                                    ErrorLog.Error("Could not parse VoipCallAppearanceState \"{0}\" for Line {1}, {2}", elements[1], lineNumber, e.Message);
                                }
                                break;

                            case "voip_call_appearance_info":
                                if (elements.Count > 3)
                                {
                                    uint lineIndex = uint.Parse(elements[1]);
                                    _CallInfoLine[lineIndex] = elements[2];
                                    if (CallInfoLineChanged != null)
                                    {
                                        CallInfoLineChanged(this, new VoipLineCallInfoLineEventArgs(lineIndex, elements[2]));
                                    }
                                }
                                break;
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLog.Error("Error parsing Voip feedback info in VoipLine[{0}], {1}", this.Number, e.Message);
                            ErrorLog.Error("VoipInfoReceived() args.Command = \"{0}\" args.Info = \"{1}\"", args.Command, args.Info);
                        }
                    }
                }
            }
        }
Esempio n. 2
0
 public VoipLineCallAppearanceStateEventArgs(uint callAppearance, VoipCallAppearanceState state)
 {
     CallAppearance = callAppearance;
     State          = state;
 }