コード例 #1
0
        protected IEnumerable <Serie <TKey, TEntry> > FindLatestForEachId(IEnumerable <ISerie <TKey, TEntry> > series)
        {
            var foundSeries = new Dictionary <TKey, Serie <TKey, TEntry> >();

            foreach (var serie in series)
            {
                var key = serie.GetKey();

                Serie <TKey, TEntry> existingSerie;
                if (!foundSeries.TryGetValue(key, out existingSerie))
                {
                    existingSerie = new Serie <TKey, TEntry>(key);
                }

                DateTimeRef latest;
                if (!_latest.TryGetValue(key, out latest))
                {
                    latest       = new DateTimeRef();
                    _latest[key] = latest;
                }

                foreach (var entry in serie.GetEntries())
                {
                    var timestamp = entry.GetTimestamp();
                    if (existingSerie.Entries.Count == 0)
                    {
                        if (timestamp > latest.Value)
                        {
                            latest.Value = timestamp;
                            existingSerie.Entries.Add(entry);
                        }
                    }
                    else
                    {
                        if (timestamp > existingSerie.Entries[0].GetTimestamp())
                        {
                            existingSerie.Entries[0] = entry;
                        }
                    }
                }

                if (existingSerie.Entries.Count > 0)
                {
                    foundSeries[key] = existingSerie;
                }
            }

            return(foundSeries.Values);
        }
コード例 #2
0
        private IEnumerator PortraitInfoRequester(DateTimeRef waitUntil, System.Action <System.Action> callback)
        {
            if (_isPullingPortraitInfo)
            {
                yield return(null);
            }

            while (System.DateTime.Now < waitUntil.Value)
            {
                yield return(wait1);
            }

            _isPullingPortraitInfo = true;

            callback(() => {
                _isPullingPortraitInfo = false;
            });

            yield break;
        }
コード例 #3
0
        public override void Connect()
        {
            State = SubSystemState.Connected;

            string portraitId = EB.Dot.String("portraitId", Hub.Instance.DataStore.LoginDataStore.LoginData, "");

            if (portraitId != "")
            {
                SetPortrait(Hub.Instance.DataStore.LoginDataStore.LocalUserId.Value, portraitId, PortraitPriority.High);
            }

            EB.Sparx.Config config  = SparxHub.Instance.Config;
            EndPointOptions options = new EndPointOptions {
                Key = config.ApiKey.Value
            };
            Hashtable social = EB.Dot.Object("social", Hub.Instance.DataStore.LoginDataStore.LoginData, null);

            if (null == social)
            {
                return;
            }

            string endpointUrl = EB.Dot.String("endpoint", social, null);

            _imageBaseUrl   = EB.Dot.String("imageBase", social, null);;
            _socialEndPoint = EndPointFactory.Create(endpointUrl, options);

            _socialEndPoint.AddData("stoken", Hub.Instance.ApiEndPoint.GetData("stoken"));
            _api.SetSocialEndpoint(_socialEndPoint);

            _allowPullFriendsPortraitInfoUntil = new DateTimeRef(System.DateTime.Now);
            _allowPullAdHocPortraitInfoUntil   = new DateTimeRef(System.DateTime.Now);

            UpdateUniqueTimestamp();
            GetFriendsPortraitInfo(null);

            Hub.Instance.GetManager <PushManager>().OnDisconnected += OnPushDisconnected;
        }