Esempio n. 1
0
 public void OnRemoveAllFences()
 {
     FenceClient.UpdateFences(new FenceUpdateRequest.Builder()
                              .RemoveFence(ExercisingWithHeadphonesKey)
                              .RemoveFence(AllHeadphonesKey)
                              .RemoveFence(AllLocationKey)
                              .RemoveFence(AroundSunriseOrSunsetKey)
                              .RemoveFence(WholeDayKey)
                              .RemoveFence(NextHourKey)
                              .RemoveFence(AnyTimeIntervalKey)
                              .Build(), () => LogSuccess("Fences successfully removed"), LogFailure);
 }
Esempio n. 2
0
    public void OnRegisterFences()
    {
        var currentTimeMillis = CurrentTimeMillis;

        FenceClient.UpdateFences(new FenceUpdateRequest.Builder()
                                 .AddFence(ExercisingWithHeadphonesKey, CreateExercisingWithHeadphonesFence())
                                 .AddFence(AllHeadphonesKey, CreateHeadphonesFence())
                                 .AddFence(AllLocationKey, CreateLocationFence())
                                 .AddFence(AllBeaconFence, CreateBeaconFence())
                                 .AddFence(AroundSunriseOrSunsetKey, CreateSunriseOrSunsetFence())
                                 .AddFence(AnyTimeIntervalKey, CreateAnyTimeIntervalFence())
                                 .AddFence(WholeDayKey, CreateWholeDayFence())
                                 .AddFence(NextHourKey, TimeFence.InInterval(currentTimeMillis, currentTimeMillis + HourInMillis))
                                 // throws FENCE_NOT_AVAILABLE for some reason
//			.AddFence("next_hour_monday, TimeFence.InIntervalOfDay(TimeFence.DayOfWeek.Monday, 0L, 24L * HourInMillis))
                                 .Build(), () => { LogSuccess("Fences successfully updated"); }, LogFailure);
    }
Esempio n. 3
0
    public void OnQueryFences()
    {
#pragma warning disable 0219
        var request = FenceQueryRequest.ForFences(AllHeadphonesKey, AllLocationKey);
#pragma warning restore 0219

        FenceClient.QueryFences(FenceQueryRequest.All(), response =>
        {
            // This callback will be executed with all fences that are currently active
            var sb = new StringBuilder();
            sb.Append("Active fences: ");
            foreach (var fenceState in response.FenceStateDictionary)
            {
                sb.AppendFormat("{0} : {1}\n", fenceState.Key, fenceState.Value);
            }

            LogSuccess(sb);
        }, LogFailure);
    }
        public void OnFenceTriggered(string fenceJson)
        {
            var fenceState = FenceState.FromJson(fenceJson);

            FenceClient.RaiseFenceEvent(fenceState);
        }