Пример #1
0
        protected override void OnUpdate()
        {
            var entity   = GetSingletonEntity <SpawnMenuArray>();
            var requests = EntityManager.GetBuffer <SpawnMenuRequest>(entity);

            if (requests.Length == 0)
            {
                return;
            }

            var array = requests.ToNativeArray(Allocator.Temp);

            requests.Clear();
            foreach (var spawnMenu in array)
            {
                var menuTemplate = MenuUtilities.GetMenuTemplate(spawnMenu.Type);
                if (menuTemplate == MenuTemplate.Null)
                {
                    continue;
                }

                var e    = GameCreateUtilities.CreateMenuItem(EntityManager);
                var menu = EntityManager.GetComponentData <MenuItem>(e);
                menu.Index       = spawnMenu.index;
                menu.ProductId   = (ushort)menuTemplate.Product;
                menu.MaterialId1 = (ushort)menuTemplate.Material1;
                menu.MaterialId2 = (ushort)menuTemplate.Material2;
                menu.MaterialId3 = (ushort)menuTemplate.Material3;
                menu.MaterialId4 = (ushort)menuTemplate.Material4;
                EntityManager.SetComponentData(e, menu);
                FSLog.Info($"Spawn Menu:{spawnMenu.Type},index:{ menu.Index }");
            }

            array.Dispose();
        }
Пример #2
0
        private async Task SendLocation(Geoposition position)
        {
            var k    = new Geolocation(position);
            var resp = await ServerAPIManager.Instance.ReportLocation(k);

            if (resp.IsSuccessful)
            {
                FSLog.Info("Location sent");
            }
            else
            {
                FSLog.Error("Failed to send location");
            }

            /*
             * // Launch a toast to show that the agent is running.
             * // The toast will not be shown if the foreground application is running.
             * ShellToast toast = new ShellToast();
             * toast.Title = "Location sent";
             * toast.Content = "";
             * toast.Show();
             */

            // Call NotifyComplete to let the system know the agent is done working.
            if (position.Coordinate.Accuracy <= LocationService.Instance.TargetAccuracy)
            {
                FSLog.Debug("Stopping");
                NotifyComplete();
            }
            else
            {
                FSLog.Debug("Waiting for more accurate position");
            }
        }
Пример #3
0
        public void Dismiss()
        {
            if (DismissAnimationStory != null)
            {
                FSLog.Debug("Already dismissing");
                return;
            }

            if (Dismissing != null)
            {
                Dismissing(this, new EventArgs());
            }

            // Hide the bubble control with fade
            DismissAnimationStory = FSAnim.Fade(this.LayoutRoot,
                                                to: 0,
                                                start: true,
                                                onCompletion: () =>
            {
                this.Visibility = Visibility.Collapsed;
                IsLoaded        = false;

                if (Dismissed != null)
                {
                    Dismissed(this, new EventArgs());
                }
                DismissAnimationStory = null;
            });
        }
Пример #4
0
            /// <summary>
            /// Starts a new GET request to given Uri
            /// </summary>
            private void StartRequest(RequestContext context, Uri uri, string method = "GET")
            {
                if (uri.Scheme != "https")
                {
                    throw new ArgumentException("https url is required");
                }

                FSLog.Info(context.Type, uri);

                Request        = (HttpWebRequest)FSRequest.Create(uri);
                Request.Method = method;

                if (Request.Headers == null)
                {
                    Request.Headers = new System.Net.WebHeaderCollection();
                }

                if (!string.IsNullOrWhiteSpace(Parent.AuthToken))
                {
                    Request.Headers["authorizationtoken"] = Parent.AuthToken;
                }

                Request.Headers["platform"] = "WP";
                Request.Headers["version"]  = "3.0";
                // No caching
                Request.Headers[HttpRequestHeader.IfModifiedSince] = DateTime.UtcNow.ToString();

                Request.BeginGetResponse(new AsyncCallback((IAsyncResult asynchronousResult) =>
                {
                    ReadCallBack(context, asynchronousResult);
                }), Request);
            }
Пример #5
0
        private Entity AttachPredictItem(EntityManager entityManager, ushort type)
        {
            var query = entityManager.CreateEntityQuery(
                ComponentType.ReadOnly <GameEntity>(),
                ComponentType.ReadOnly <ReplicatedEntityData>(),
                ComponentType.ReadOnly <PredictedItem>());

            var entities = query.ToEntityArray(Allocator.TempJob);

            foreach (var entity in entities)
            {
                var replicatedEntityData = entityManager.GetComponentData <ReplicatedEntityData>(entity);
                var gameEntity           = entityManager.GetComponentData <GameEntity>(entity);

                if ((ushort)gameEntity.Type != type || replicatedEntityData.Id != -1)
                {
                    continue;
                }

                entityManager.RemoveComponent <PredictedItem>(entity);
                entities.Dispose();

                FSLog.Info($"Attach Predict item:{entity}");
                return(entity);
            }

            entities.Dispose();
            return(Entity.Null);
        }
Пример #6
0
        static int Main(string[] aArguments)
        {
            int error = CACmdLineException.KErrNone;

            //
            using (FSLog log = new FSLog(true))
            {
                try
                {
                    FSUtilities.ClearTempPath();
                    //
                    CACommandLineUI commandLineUi = new CACommandLineUI(aArguments, log);
                    error = commandLineUi.Run();
                    //
                    if (error != CACmdLineException.KErrNone)
                    {
                        SymbianUtils.SymDebug.SymDebugger.Break();
                    }
                }
                catch (Exception e)
                {
                    log.TraceAlways("CrashAnalyserServerExe.Main() - EXCEPTION: " + e.Message);
                    log.TraceAlways("CrashAnalyserServerExe.Main() - STACK:     " + e.StackTrace);
                    SymbianUtils.SymDebug.SymDebugger.Break();
                    error = -1;
                }
                //
                if (error != 0)
                {
                    log.TraceAlways("CA completed with error: " + error);
                }
            }
            //
            return(error);
        }
Пример #7
0
        protected override void OnUpdate()
        {
            Entities.WithAll <ServerEntity, Plate>()
            .WithStructuralChanges()
            .ForEach((Entity entity,
                      in PlatePredictedState plateState,
                      in OwnerPredictedState itemState,
                      in PlateServedRequest request) =>
            {
                FSLog.Info("PlateServedSystem OnUpdate");

                //add score
                ushort score = CalculateScore(plateState.Product);
                AddScore(score);

                EntityManager.RemoveComponent <PlateServedRequest>(entity);

                //Despawn
                Despawn(entity);

                EntityManager.SetComponentData(itemState.Owner, new SlotPredictedState()
                {
                    FilledIn = Entity.Null
                });
            }).Run();
Пример #8
0
        public async Task <ResponseBase> RegisterNotificationUrl()
        {
            if (SettingsManager.IsNotificationUrlRegistered)
            {
                // Already registered
                return(null);
            }

            FSLog.Info("Not registered yet");

            // Register notification token, this is used to track the type of devices being used
            // at the moment. "W" is used as a workaround for missing token.
            var tokenResp = await this.Request.RegisterNotificationUrl("W");

            if (!tokenResp.IsSuccessful)
            {
                // NOTE: Not failing if this fails.
                FSLog.Error("Failed to register token");
            }
            else
            {
                FSLog.Info("Notification token sent");
                SettingsManager.IsNotificationUrlRegistered = true;
            }

            return(tokenResp);
        }
Пример #9
0
        protected override void OnUpdate()
        {
            if (network.connectionState == NetworkClient.ConnectionState.Disconnected)
            {
                var ip = "58.247.94.202:7913";
                // var ip = "192.168.0.115:29180";
                if (DataManager.Instance.RoomDataManager != null)
                {
                    if (!DataManager.Instance.RoomDataManager.IsTestMod)
                    {
                        ip = DataManager.Instance.RoomDataManager.CurRoomInfo.host + ":" + DataManager.Instance.RoomDataManager.CurRoomInfo.port;
                    }
                }

                // var ip = "220.229.229.91";
                FSLog.Info($"network.Connect:{ip}");
                network.Connect(ip);
            }


            network.Update(this, replicateEntitySystemGroup);

            var snapshotFromServer = GetSingleton <ServerSnapshot>();

            snapshotFromServer.ServerTick        = (uint)network.serverTime;
            snapshotFromServer.TimeSinceSnapshot = network.timeSinceSnapshot;
            snapshotFromServer.Rtt = network.rtt;
            snapshotFromServer.LastAcknowledgedTick = network.lastAcknowlegdedCommandTime;
            SetSingleton(snapshotFromServer);
        }
Пример #10
0
        public void ProcessEntitySpawn(int serverTick, int id, ushort typeId)
        {
            FSLog.Info("ProcessEntitySpawns. Server tick:" + serverTick + " id:" + id + " typeid:" + (EntityType)typeId);

            Profiler.BeginSample("ReplicatedEntitySystemClient.ProcessEntitySpawns()");

            if (id < worldSceneEntitiesSystem.SceneEntities.Count)
            {
                replicatedEntities.Register(id, worldSceneEntitiesSystem.SceneEntities[id]);
                return;
            }

            var factory = factoryManager.GetFactory(typeId);

            if (factory == null)
            {
                return;
            }

            var entity = factory.Create(EntityManager, null, null, typeId);

            if (entity == Entity.Null)
            {
                return;
            }

            var replicatedDataEntity = EntityManager.GetComponentData <ReplicatedEntityData>(entity);

            replicatedDataEntity.Id = id;
            EntityManager.SetComponentData(entity, replicatedDataEntity);

            replicatedEntities.Register(id, entity);

            Profiler.EndSample();
        }
Пример #11
0
        /// <summary>
        /// Starts reporting position via LocationChanged event.
        /// First the position is observed with high accuracy(reporting phase),
        /// the most accurate position received during short period of time is sent
        /// via LocationChanged event. After that it enters a low power mode(idle phase)
        /// keeping the GeoLocation active to allow app running in the background for some
        /// minutes and triggers the reporting phase again.
        /// </summary>
        public void Start()
        {
            FSLog.Debug();
            if (Timer != null)
            {
                FSLog.Info("Already started");
                return;
            }

#if HAVE_IDLE_LOCATOR
            IdleLocator = new Geolocator();
            IdleLocator.DesiredAccuracy         = PositionAccuracy.Default;
            IdleLocator.DesiredAccuracyInMeters = 5000;
            IdleLocator.MovementThreshold       = 1000;
            IdleLocator.ReportInterval          = 10 * 1000 * 60;

            IdleLocator.PositionChanged += IdleLocator_PositionChanged;
#endif
            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                Timer = new DispatcherTimer();

                SetReportingMode(ReportingMode.Reporting);

                Timer.Tick += Timer_Tick;
            });
        }
Пример #12
0
        /// <summary>
        /// Signup to Lokki service with email
        /// </summary>
        public async Task <SignupResponse> Signup(string email)
        {
            var current = SettingsManager.CurrentUser;

            current.Email = email;

            SignupResponse resp = await Request.Signup(email, DeviceId);

            // Store user id and auth if successful
            if (resp.IsSuccessful)
            {
                FSLog.Info("Signup successful");

                SettingsManager.AuthToken = resp.AuthorizationToken;
                this.Request.AuthToken    = SettingsManager.AuthToken;
                this.Request.UserId       = resp.Id;

                current.BackendId = resp.Id;

                SettingsManager.SavePeople();

                await RegisterNotificationUrl();
            }
            else
            {
                FSLog.Error("Signup failed:", resp.HttpStatus, resp.Error);
            }

            return(resp);
        }
Пример #13
0
        void NotificationService_ChannelUriUpdated(object sender, NotificationChannelUriEventArgs e)
        {
            FSLog.Info("Channel URL: ", e.ChannelUri.ToString());

            // update URI to settings
            SettingsManager.NotificationChannelUriString = e.ChannelUri.ToString();
        }
Пример #14
0
        void NotificationService_ErrorOccurred(object sender, NotificationChannelErrorEventArgs e)
        {
            FSLog.Error("Push notification error {0} occured. {1} {2} {3}", e.ErrorType, e.Message, e.ErrorCode, e.ErrorAdditionalData);

            Stop();
            Start();
        }
Пример #15
0
        /// <summary>
        /// Toggle user's visibility to others.
        /// </summary>
        public async void ToggleVisibility()
        {
            SystemTrayProgressIndicator.TaskCount++;
            try
            {
                var previous = SettingsManager.CurrentUser.IsVisible;
                // Toggle
                var visible = previous == false;

                // Change immediately to show something happened
                SettingsManager.CurrentUser.IsVisible = visible;
                Dispatcher.BeginInvoke(UpdateVisibilityIcon);

                // Send
                var resp = await ServerAPIManager.Instance.ChangeVisibility(visible);

                if (!resp.IsSuccessful)
                {
                    FSLog.Error("Failed to update visibility");
                    SettingsManager.CurrentUser.IsVisible = previous;
                    Dispatcher.BeginInvoke(UpdateVisibilityIcon);
                }
            }
            finally
            {
                SystemTrayProgressIndicator.TaskCount--;
            }
        }
Пример #16
0
        void person_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var person = sender as Person;

            if (e.PropertyName == "IsVisible" || e.PropertyName == "ICanSee" || e.PropertyName == "CanSeeMe")
            {
                // Remove people who don't want to be visible except current user
                if (!CanSeePerson(person))
                {
                    FindAndRemoveFromPlaces(person);
                }
                else
                {
                    FindAndAddToPlaces(person);
                }
            }
            // Update places for person
            else if (e.PropertyName == "Position")
            {
                FSLog.Info("Updating position");

                // Find places where the person is no more and remove from respective control
                foreach (Place place in SettingsManager.Places)
                {
                    if (!IsPersonAtPlace(person, place))
                    {
                        FSLog.Info("Removing from place");
                        place.People.Remove(person);
                    }
                }

                // Find if there are any new places.
                FindAndAddToPlaces(person);
            }
        }
Пример #17
0
        public static void Check()
        {
            // For testing
            //SettingsManager.AppRaterShown = false;
            //SettingsManager.AppRaterDoYouLikeQuestionShown = false;
            //SettingsManager.AppRaterQueryDate = DateTimeOffset.UtcNow;

            if (SettingsManager.AppRaterShown)
            {
                return;
            }

            if (SettingsManager.AppStartCount < MinimumAppStarts)
            {
                FSLog.Debug("Not enough app starts", SettingsManager.AppStartCount, "<", MinimumAppStarts);
                return;
            }

            var queryDate = SettingsManager.AppRaterQueryDate;

            if (queryDate.CompareTo(DateTimeOffset.UtcNow) <= 0)
            {
                if (!SettingsManager.AppRaterDoYouLikeQuestionShown)
                {
                    ShowDoYouLikeDialog();
                }
                else
                {
                    ShowUserLikesRateDialog();
                }
            }
        }
Пример #18
0
        private static void WithLocking(Action action)
        {
            // http://stackoverflow.com/questions/15456986/how-to-gracefully-get-out-of-abandonedmutexexception
            // "if you can assure the integrity of the data structures protected by the mutex you can simply ignore the exception and continue executing your application normally."
            // The bg agent can terminate and the mutex is not released properly
            try
            {
                ThreadLocker.WaitOne();
            }
            catch (AbandonedMutexException e)
            {
                FSLog.Exception(e);
            }
            catch (Exception e)
            {
                FSLog.Exception(e);
            }

            try
            {
                action();
            }
            finally
            {
                ThreadLocker.ReleaseMutex();
            }
        }
Пример #19
0
        protected override void OnUpdate()
        {
            Entities
            .WithStructuralChanges()
            .ForEach((Entity entity,
                      ref GameStateComponent gameState,
                      ref Countdown countdown) =>
            {
                if (gameState.State != GameState.Ending)
                {
                    return;
                }

                var query = GetEntityQuery(new EntityQueryDesc
                {
                    All = new ComponentType[]
                    {
                        typeof(Character)
                    }
                });
                if (query.CalculateEntityCount() == 0)
                {
                    return;
                }

                gameState.State        = GameState.Preparing;
                gameState.IsSceneReady = false;
                countdown.SetValue(5);


                FSLog.Info($"Game Prepare");
            }).Run();
        }
Пример #20
0
        // Code to execute when the application is launching (eg, from Start)
        // This code will not execute when the application is reactivated
        private void Application_Launching(object sender, LaunchingEventArgs e)
        {
            FSLog.Info();
#if HAVE_BACKGROUND_RUNNING
            RunningInBackground = false;
#endif
            RemoveAgent();
        }
Пример #21
0
        private void Application_RunningInBackground(object sender, RunningInBackgroundEventArgs args)
        {
            FSLog.Info("Entering background");
            LogMemoryInfo();
#if HAVE_BACKGROUND_RUNNING
            RunningInBackground = true;
#endif
        }
Пример #22
0
        /// <summary>
        /// Remind the next day
        /// </summary>
        private static void ResetQueryDateToRemind()
        {
            var date = DateTimeOffset.UtcNow.Add(TimeSpan.FromDays(1));

            FSLog.Info(date);

            SettingsManager.AppRaterQueryDate = date;
        }
Пример #23
0
        /// <summary>
        /// Triggered when OS has detected a position change
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        private void Locator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            var coord = args.Position.Coordinate;

            if (IsReportingPhaseActive)
            {
                double curacc = double.MaxValue;
                if (BestPosition != null)
                {
                    curacc = BestPosition.Coordinate.Accuracy;
                }
                var newacc = args.Position.Coordinate.Accuracy;

                FSLog.Debug("time:", args.Position.Coordinate.Timestamp);

                /* Disabled for now
                 * var lastAcceptedTime = new DateTimeOffset(DateTime.Now - MaximumLocationAge);
                 * if (args.Position.Coordinate.Timestamp < lastAcceptedTime)
                 * {
                 *  FSLog.Debug("Position too old:", args.Position.Coordinate.Timestamp,
                 *      "<", lastAcceptedTime);
                 *  return;
                 * }*/

                if (BestPosition == null ||
                    BestPosition.Coordinate.Accuracy > args.Position.Coordinate.Accuracy)
                {
                    FSLog.Debug("Best position with acc:",
                                args.Position.Coordinate.Accuracy);
                    BestPosition = args.Position;

                    if (newacc <= TargetAccuracy)
                    {
                        FSLog.Debug("Target accuracy reached, report and stop");

                        // Trigger Timer now
                        Deployment.Current.Dispatcher.BeginInvoke(() =>
                        {
                            // If null, already sent by timer
                            if (BestPosition != null)
                            {
                                ToggleMode();
                            }
                        });
                    }
                    else
                    {
                        if (newacc <= MinAccuracy)
                        {
                            FSLog.Debug("Good enough accuracy reached, report and continue");
                            OnLocationChanged(BestPosition, isForced: false);
                        }
                    }
                }
            }
        }
Пример #24
0
        /// Code to execute on Unhandled Exceptions
        private static void UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            FSLog.Exception(e.ExceptionObject);

            if (Debugger.IsAttached)
            {
                // An unhandled exception has occurred; break into the debugger
                Debugger.Break();
            }
        }
Пример #25
0
        private static void ShowDoYouLikeDialog()
        {
            FSLog.Info();
            var messageBox = MessageBoxQueue.Instance.Show(Localized.AppRaterDoYouLikeTitle,
                                                           Localized.AppRaterDoYouLikeQuestion,
                                                           leftButtonContent: Localized.AppRaterYes,
                                                           rightButtonContent: Localized.AppRaterNo);

            messageBox.Dismissed += ShowUserDislikesDialog_Dismissed;
        }
Пример #26
0
        public async Task <ResponseBase> DisallowContactToSeeMe(Person person)
        {
            var resp = await Request.DisallowContactToSeeMe(person.BackendId);

            if (!resp.IsSuccessful)
            {
                FSLog.Error("Request failed");
            }
            return(resp);
        }
Пример #27
0
        // Code to execute if a navigation fails
        private void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e)
        {
            FSLog.Exception(e.Exception);

            if (System.Diagnostics.Debugger.IsAttached)
            {
                // A navigation has failed; break into the debugger
                System.Diagnostics.Debugger.Break();
            }
        }
Пример #28
0
 public static void Initialize(TimeSpan checkTimeSpan, int minimumAppStarts)
 {
     MinimumAppStarts = minimumAppStarts;
     if (SettingsManager.AppRaterQueryDate == null ||
         SettingsManager.AppRaterQueryDate == default(DateTimeOffset))
     {
         SettingsManager.AppRaterQueryDate = DateTimeOffset.UtcNow + checkTimeSpan;
         FSLog.Info(SettingsManager.AppRaterQueryDate);
     }
 }
Пример #29
0
        /** SMSComposer.showSMSComposer( { toRecipients : "number1;number2", body : "message" } ) */
        public static void showSMSComposer(List <string> to, string body)
        {
            FSLog.Info();

            var task = new SmsComposeTask();

            task.To   = string.Join(";", to); // multiple separated with semicolon
            task.Body = body;
            task.Show();
        }
Пример #30
0
        public static void shareLink(Uri link, string message, string title)
        {
            FSLog.Info();

            var task = new ShareLinkTask();

            task.LinkUri = link;
            task.Message = message;
            task.Title   = title;
            task.Show();
        }