Esempio n. 1
0
 public void EvaluateReadyness()
 {
     this.readyness = GetReadyness();
 }
Esempio n. 2
0
        // Notify
        public void Notify(SSEResultState state, string data)
        {
            // Console.WriteLine($"received {state} with object {data}");

            switch (state)
            {
            case SSEResultState.Ack:
                break;

            case SSEResultState.Bye:
                // swap to not ready and let everyone know
                _readyness = Readyness.NotReady;
                TriggerReadyness();
                break;

            case SSEResultState.Failure:
                _readyness = Readyness.Failed;
                TriggerReadyness();
                break;

            case SSEResultState.Features:
                if (data != null)
                {
                    List <FeatureState> features = JsonConvert.DeserializeObject <List <FeatureState> >(data);
                    var updated = false;
                    foreach (var featureState in features)
                    {
                        updated = FeatureUpdate(featureState) || updated;
                    }

                    if (_readyness != Readyness.Ready)
                    {
                        // are we newly ready?
                        _readyness = Readyness.Ready;
                        TriggerReadyness();
                    }

                    // we updated something, so let the folks know
                    if (updated)
                    {
                        TriggerNewUpdate();
                    }
                }

                break;

            case SSEResultState.Feature:
                if (data != null)
                {
                    if (FeatureUpdate(JsonConvert.DeserializeObject <FeatureState>(data)))
                    {
                        TriggerNewUpdate();
                    }
                }

                break;

            case SSEResultState.Deletefeature:
                if (data != null)
                {
                    DeleteFeature(JsonConvert.DeserializeObject <FeatureState>(data));
                }

                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }
        }
Esempio n. 3
0
 private void Update()
 {
     readyness = GetReadyness();
 }