private void HandleNewsInfo(ParseData data)
        {
            DateTime UNIX_EPOCH = new DateTime(1970, 1, 1).ToUniversalTime();

            DataReader dr = new DataReader(data.Data);
            int        numEntriesInPacket = dr.ReadByte();

            dr.ReadInt32(); // last login timestamp
            dr.Seek(8);     // oldest news, newest news timestamps.
            //int oldestNews = dr.ReadInt32();
            //int newestNews = dr.ReadInt32();

            //DateTime oldestNewsDateUtc = UNIX_EPOCH + TimeSpan.FromSeconds(oldestNews);
            //DateTime oldestNewsDateLocal = oldestNewsDateUtc.ToLocalTime();
            //DateTime newestNewsDateUtc = UNIX_EPOCH + TimeSpan.FromSeconds(newestNews);
            //DateTime newestNewsDateLocal = newestNewsDateUtc.ToLocalTime();

            lock (m_news)
            {
                for (int i = 0; i < numEntriesInPacket; i++)
                {
                    int      newsTS      = dr.ReadInt32();
                    DateTime newsDateUtc = UNIX_EPOCH + TimeSpan.FromSeconds(newsTS);
                    if (newsTS == 0)
                    {
                        newsDateUtc = DateTime.UtcNow;
                    }

                    string    text = dr.ReadCString();
                    NewsEntry news = new NewsEntry(newsDateUtc, text);
                    OnServerNews(new ServerNewsEventArgs(news));
                }

                BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
            }
        }
        /// <summary>
        /// Creates a new instance of <see>ServerNewsEventArgs</see>.
        /// </summary>
        /// <param name="entry">The entry for this news event.</param>
        public ServerNewsEventArgs(NewsEntry entry)
        {
            Debug.Assert(entry != null);

            m_entry = entry;
        }
        private void HandleNewsInfo(ParseData data)
        {
            DateTime UNIX_EPOCH = new DateTime(1970, 1, 1).ToUniversalTime();

            DataReader dr = new DataReader(data.Data);
            int numEntriesInPacket = dr.ReadByte();
            dr.ReadInt32(); // last login timestamp
            dr.Seek(8); // oldest news, newest news timestamps.
            //int oldestNews = dr.ReadInt32();
            //int newestNews = dr.ReadInt32();

            //DateTime oldestNewsDateUtc = UNIX_EPOCH + TimeSpan.FromSeconds(oldestNews);
            //DateTime oldestNewsDateLocal = oldestNewsDateUtc.ToLocalTime();
            //DateTime newestNewsDateUtc = UNIX_EPOCH + TimeSpan.FromSeconds(newestNews);
            //DateTime newestNewsDateLocal = newestNewsDateUtc.ToLocalTime();

            lock (m_news)
            {
                for (int i = 0; i < numEntriesInPacket; i++)
                {
                    int newsTS = dr.ReadInt32();
                    DateTime newsDateUtc = UNIX_EPOCH + TimeSpan.FromSeconds(newsTS);
                    if (newsTS == 0)
                        newsDateUtc = DateTime.UtcNow;

                    string text = dr.ReadCString();
                    NewsEntry news = new NewsEntry(newsDateUtc, text);
                    OnServerNews(new ServerNewsEventArgs(news));
                }

                BattleNetClientResources.IncomingBufferPool.FreeBuffer(data.Data);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Creates a new instance of <see>ServerNewsEventArgs</see>.
        /// </summary>
        /// <param name="entry">The entry for this news event.</param>
        public ServerNewsEventArgs(NewsEntry entry)
        {
            Debug.Assert(entry != null);

            m_entry = entry;
        }