コード例 #1
0
        public static IEnumerator GetCounter(
            Client client,
            GameSession session,
            string limitNamespaceName,
            EzLimitModel limitModel,
            string counterName,
            GetCounterEvent onGetCounter,
            ErrorEvent onError
            )
        {
            AsyncResult <EzGetCounterResult> result = null;

            yield return(client.Limit.GetCounter(
                             r =>
            {
                result = r;
            },
                             session,
                             limitNamespaceName,
                             limitModel.Name,
                             counterName
                             ));

            if (result.Error != null)
            {
                onError.Invoke(
                    result.Error
                    );
                yield break;
            }

            var counter = result.Result.Item;

            onGetCounter.Invoke(limitModel, counter);
        }
コード例 #2
0
 public EzGetLimitModelResult(
     GetLimitModelResult result
     )
 {
     if (result.item != null)
     {
         Item = new EzLimitModel(result.item);
     }
 }
コード例 #3
0
        private void CountUpAction(
            EzLimitModel limitModelTemp,
            EzCounter counter,
            int countUpValue
            )
        {
            if (limitModelTemp.Name != _limitModel.Name)
            {
                return;
            }

            _counters[counter.Name] = counter;
        }
コード例 #4
0
        public static IEnumerator ListCounters(
            Client client,
            GameSession session,
            string limitNamespaceName,
            EzLimitModel limitModel,
            GetCounterEvent onGetCounter,
            ErrorEvent onError
            )
        {
            var counters = new List <EzCounter>();

            string pageToken = null;

            while (true)
            {
                AsyncResult <EzListCountersResult> result = null;
                yield return(client.Limit.ListCounters(
                                 r =>
                {
                    result = r;
                },
                                 session,
                                 limitNamespaceName,
                                 limitModel.Name,
                                 pageToken,
                                 30
                                 ));

                if (result.Error != null)
                {
                    onError.Invoke(
                        result.Error
                        );
                    yield break;
                }

                counters.AddRange(result.Result.Items);
                pageToken = result.Result.NextPageToken;

                if (pageToken == null)
                {
                    break;
                }
            }

            foreach (var counter in counters)
            {
                onGetCounter.Invoke(limitModel, counter);
            }
        }
コード例 #5
0
        public IEnumerator Refresh()
        {
            void RefreshLimitModelAction(
                string namespaceName,
                EzLimitModel limitModelTemp
                )
            {
                _limitModel = limitModelTemp;

                _onGetLimitModel.RemoveListener(RefreshLimitModelAction);
            }

            void RefreshCounterAction(
                EzLimitModel limitModelTemp,
                EzCounter counter
                )
            {
                if (limitModelTemp.Name != _limitModel.Name)
                {
                    return;
                }

                _limitModel             = limitModelTemp;
                _counters[counter.Name] = counter;

                _onGetCounter.RemoveListener(RefreshCounterAction);
            }

            _onGetLimitModel.AddListener(RefreshLimitModelAction);
            _onGetCounter.AddListener(RefreshCounterAction);

            yield return(LimitController.GetLimitModel(
                             _client,
                             _limitNamespaceName,
                             _limitModelName,
                             _onGetLimitModel,
                             _onError
                             ));

            yield return(LimitController.ListCounters(
                             _client,
                             _session,
                             _limitNamespaceName,
                             _limitModel,
                             _onGetCounter,
                             _onError
                             ));
        }
コード例 #6
0
        public static IEnumerator CountUp(
            Client client,
            GameSession session,
            string limitNamespaceName,
            EzLimitModel limitModel,
            string counterName,
            int countUpValue,
            CountUpEvent onCountUp,
            ErrorEvent onError
            )
        {
            AsyncResult <EzCountUpResult> result = null;

            yield return(client.Limit.CountUp(
                             r =>
            {
                result = r;
            },
                             session,
                             limitNamespaceName,
                             limitModel.Name,
                             counterName,
                             countUpValue
                             ));

            if (result.Error != null)
            {
                onError.Invoke(
                    result.Error
                    );
                yield break;
            }

            var counter = result.Result.Item;

            onCountUp.Invoke(limitModel, counter, countUpValue);
        }