Exemplo n.º 1
0
        internal override void UpdateFromResponse(TesiraResponse response)
        {
#if DEBUG
            Debug.WriteSuccess(ControlBlock.InstanceTag + " Line " + ChannelNumber,
                               "Received {0} response for {1}: {2}", response.CommandType, response.AttributeCode,
                               response.TryParseResponse().ToString());
#endif
            switch (response.AttributeCode)
            {
            case TesiraAttributeCode.LineLabel:
                _lineLabel = response.TryParseResponse()["value"].Value <string>();
                break;
            }
        }
Exemplo n.º 2
0
        internal override void UpdateFromResponse(TesiraResponse response)
        {
            base.UpdateFromResponse(response);

            if (response.CommandType == TesiraCommand.Get)
            {
                switch (response.AttributeCode)
                {
                case TesiraAttributeCode.Label:
                    _label = response.TryParseResponse()["value"].Value <string>();
                    break;
                }
            }
        }
Exemplo n.º 3
0
        protected override void ReceivedResponse(TesiraResponse response)
        {
            if (response.CommandType != TesiraCommand.Get || response.OtherCommandElements.Any())
            {
                return;
            }

            var json = response.TryParseResponse();

            if (json == null)
            {
                CloudLog.Error("{0} could not parse {1} value from json message \"{2}\"", GetType().Name,
                               response.AttributeCode, response.Message);
                return;
            }

            try
            {
                switch (response.AttributeCode)
                {
                case TesiraAttributeCode.Label:
                    _label = response.TryParseResponse()["value"].Value <string>();
                    break;

                case TesiraAttributeCode.NumInputs:
                    _numberOfInputs = response.TryParseResponse()["value"].Value <uint>();
                    break;

                case TesiraAttributeCode.NumOutputs:
                    _numberOfOutputs = response.TryParseResponse()["value"].Value <uint>();
                    break;

                case TesiraAttributeCode.NumSources:
                    _numberOfSources = response.TryParseResponse()["value"].Value <uint>();
                    break;

                case TesiraAttributeCode.SourceSelection:
                    _sourceSelection = response.TryParseResponse()["value"].Value <uint>();
                    break;

                case TesiraAttributeCode.StereoEnable:
                    _stereroEnabled = response.TryParseResponse()["value"].Value <bool>();
                    OnInitialized();
                    break;
                }
            }
            catch (Exception e)
            {
                CloudLog.Error("{0} could not parse {1} value from json \"{2}\", {3}", GetType().Name,
                               response.AttributeCode, json.ToString(), e.Message);
            }
        }
Exemplo n.º 4
0
        protected override void ReceivedResponse(TesiraResponse response)
        {
            if (response.OtherCommandElements.Any())
            {
                try
                {
                    var channel = uint.Parse(response.OtherCommandElements.First());
#if DEBUG
                    Debug.WriteInfo("Response for channel " + channel);
#endif
                    if (_channels.ContainsKey(channel))
                    {
                        _channels[channel].UpdateFromResponse(response);
                        return;
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Exception(e, "Should be response with index");
                }
            }

            if (response.CommandType != TesiraCommand.Get || response.OtherCommandElements.Any())
            {
                return;
            }

            var json = response.TryParseResponse();

            if (json == null)
            {
                CloudLog.Error("{0} could not parse {1} value from json message \"{2}\"", GetType().Name,
                               response.AttributeCode, response.Message);
                return;
            }
        }
Exemplo n.º 5
0
        protected override void ReceivedResponse(TesiraResponse response)
        {
            if (response.OtherCommandElements.Any())
            {
                try
                {
                    var channel = uint.Parse(response.OtherCommandElements.First());
#if DEBUG
                    Debug.WriteInfo("Response for channel " + channel);
#endif
                    if (_channels.ContainsKey(channel))
                    {
                        _channels[channel].UpdateFromResponse(response);
                        return;
                    }
                }
                catch (Exception e)
                {
                    CloudLog.Exception(e, "Should be response with index");
                }
            }

            if (response.CommandType != TesiraCommand.Get || response.OtherCommandElements.Any())
            {
                return;
            }

            var json = response.TryParseResponse();

            if (json == null)
            {
                CloudLog.Error("{0} could not parse {1} value from json message \"{2}\"", GetType().Name,
                               response.AttributeCode, response.Message);
                return;
            }

            try
            {
                switch (response.AttributeCode)
                {
                case TesiraAttributeCode.NumChannels:
                    var numberOfChannels = json["value"].Value <uint>();
                    for (uint i = 1; i <= numberOfChannels; i++)
                    {
                        if (!_channels.ContainsKey(i))
                        {
                            CloudLog.Debug("Creating Dialer Line {0}, i");
                            _channels[i] = new DialerLine(this, i);
                        }
                    }
                    OnInitialized();
                    break;

                case TesiraAttributeCode.CallState:
                    var callStates = json["value"]["callState"].ToObject <List <CallState> >();
                    foreach (var line in _channels)
                    {
                        var statesForLine = callStates.Where(c => c.LineId == (line.Key - 1));
                        line.Value.UpdateCallStates(statesForLine);
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                CloudLog.Error("{0} could not parse {1} value from json \"{2}\", {3}", GetType().Name,
                               response.AttributeCode, json.ToString(), e.Message);
            }
        }