Exemple #1
0
 void Device_VoipInfoReceived(ISoundstructureItem item, SoundstructureVoipInfoReceivedEventArgs args)
 {
     if (item == this)
     {
         OnVoipInfoReceived(args.Command, args.Info);
     }
 }
Exemple #2
0
        void VoipInfoReceived(ISoundstructureItem item, SoundstructureVoipInfoReceivedEventArgs args)
        {
            if (item != VoipOutChannel)
            {
                return;
            }
            var elements = SoundstructureSocket.ElementsFromString(args.Info);

            if (elements.Count <= 1)
            {
                return;
            }
            var lineNumber = uint.Parse(elements[0]);

            if (lineNumber != Number)
            {
                return;
            }
            try
            {
                switch (args.Command)
                {
                case "voip_line_state":
                    try
                    {
                        State = (VoipLineState)Enum.Parse(typeof(VoipLineState), elements[1], true);
                        if (StateChanged != null)
                        {
                            StateChanged(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":
                    Label = elements[1];
                    break;

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

                case "voip_call_appearance_state":
                    try
                    {
                        var state = (VoipCallAppearanceState)Enum.Parse(typeof(VoipCallAppearanceState), elements[1], true);
                        if (CallAppearanceState != state)
                        {
                            CallAppearanceState = state;
                            if (CallAppearanceState == VoipCallAppearanceState.Connected)
                            {
                                _callConnectedTime = DateTime.Now;
                            }
                        }
                        try
                        {
                            if (CallAppearanceStateChanged != null)
                            {
                                CallAppearanceStateChanged(this, new VoipLineCallAppearanceStateEventArgs(CallAppearance, CallAppearanceState));
                            }
                        }
                        catch (Exception e)
                        {
                            ErrorLog.Exception(string.Format("Error calling event {0}.CallAppearanceStateChanged", 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":
                    // Not sure why this was > 3 instead of >= 3 !?!
                    if (elements.Count >= 3)
                    {
                        var 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}", Number, e.Message);
                ErrorLog.Error("VoipInfoReceived() args.Command = \"{0}\" args.Info = \"{1}\"", args.Command, args.Info);
            }
        }