Пример #1
0
        private void _handlePlayerPreferences(IMessageBase messageBase)
        {
            PreferencesMessage preferences = (PreferencesMessage)messageBase;

            Logger.Debug("Received new player preferences from P" + preferences.UserId);
            if (preferences == null)
            {
                Logger.Warn("Received invalid message type " + messageBase.GetType() +
                            ". Expected " + typeof(PreferencesMessage));
                return;
            }
            if (preferences.UserId < 0)
            {
                Logger.Warn("Received invalid player id " + preferences.UserId);
                return;
            }
            if (!PlayerData.Instance.TryGetEntry(preferences.UserId, out PlayerDataEntry entry))
            {
                Logger.Warn("Received unregistered player id " + preferences.UserId);
                return;
            }

            entry.UpdatePreferences(preferences.preferences);
            SendToFrontend(new FrontendPayload(preferences));
            MetricLogger.Log(preferences.UserId + " reregistered as " + preferences.preferences.SceneName);
        }
        private BackendWorker()
        {
            MetricLogger = new MetricLogger(PlayerData.Instance, EventMap.Instance);
            MetricLogger.StartNewLogging();

            _sessionIds = new ConcurrentDictionary <int, int>();
            _setEventHandler();

            _intersections = new List <ManagedAllocationIntersection>();

            _workerThread          = new Thread(_workerLoop);
            _workerThread.Priority = ThreadPriority.AboveNormal;

            _sendTimeTask     = new Task(_sendTimeLoop);
            _sendFrontendTask = new Task(_sendFrontendLoop);

            _sendTimeTask.Start();
            _sendFrontendTask.Start();

            Logger.AddPrinter(new ConsolePrinter());
            //EventMap.Instance.InitializeLogging();
        }