Esempio n. 1
0
        private void OnGetGlobalDataRequestReceived(TriviaMessage message, Socket socket)
		{
            Stats stats = new Stats();

            stats.PointsEarnedByHour = StatsAccess.PointsEarnedByHour() ?? new int[0];
            stats.PointsMaximumByHour = StatsAccess.PointsMaxByHour() ?? new int[0];

            GlobalData gd = new GlobalData
            {
                Links = LinkAccess.GetAllLinks(),
                CurrentCaller = "mgncallerhardcoded",
                Stats = stats
            };

			TriviaMessage responseMessage = MessageParser.CreateGetGlobalDataResponse(gd);

			this.mServer.SendMessageToSpecificClient(responseMessage, socket);
		}
Esempio n. 2
0
        private GlobalData CreateGlobalData()
        {
            Stats stats = new Stats();

            stats.PointsEarnedByHour = StatsAccess.PointsEarnedByHour() ?? new int[0];
            stats.PointsMaximumByHour = StatsAccess.PointsMaxByHour() ?? new int[0];

            GlobalData gd = new GlobalData
            {
                Links = LinkAccess.GetAllLinks(),
                CurrentCaller = null,
                Stats = stats
            };

            return gd;
        }
Esempio n. 3
0
        private static void LoadGlobalDataIntoViewModel(GlobalData globalData, TriviaViewModel viewModel)
        {
            /* 
             * comment below is not true - we load global data unnecesarily repeatedly every time we GetCompleteHourData.  Optimized?  No.  But that's ok.
             * 
            // It really ought to be sufficient to load Global Data once at startup.  Detect duplicate load because that's probably a subtle bug
            if (viewModel.Links.Count > 0)
            {
                throw new InvalidOperationException("Got GlobalData response when we already have Links");
            }
             */

            LoadStatsIntoViewModel(globalData.Stats, viewModel);
            LoadLinksIntoViewModel(globalData.Links, viewModel);
        }