Ejemplo n.º 1
0
        /// <summary>
        /// Creates a new realtime query
        /// </summary>
        /// <param name="query">The core query to base this request on</param>
        /// <param name="slowAndSafe">Should the system try catch each event called?</param>
        /// <param name="runOnMainThread">Shoud the system make sure the events will only be called on the main thread</param>
        /// <param name="parseClient">an override to the parse client</param>
        /// <param name="parseLiveQueryClient">an overide to the live query client</param>
        /// <param name="enterFiresUpdate">when an object enters the query a update event will be called after enter</param>
        public RealtimeQuery(ParseQuery <T> query, bool slowAndSafe = false, bool runOnMainThread = true, ParseClient parseClient = null, ParseLiveQueryClient parseLiveQueryClient = null, bool enterFiresUpdate = true)
        {
            if (!ContextCache.IsInitialized)
            {
                ContextCache.Initialize();
            }

            // Get the collections started
            watchedObjects      = new Dictionary <string, T>();
            OnEnterListeners    = new List <Action <T> >();
            OnCreateListeners   = new List <Action <T> >();
            OnUpdateListeners   = new List <Action <T> >();
            OnLeaveListeners    = new List <Action <T> >();
            OnDeleteListeners   = new List <Action <T> >();
            OnDestroyListenters = new List <Action>();

            this.query            = query;
            this.slowAndSafe      = slowAndSafe;
            this.runOnMainThread  = runOnMainThread;
            this.enterFiresUpdate = enterFiresUpdate;

            // look to see if there is a ParseClientOverride
            if (parseClient == null)
            {
                this.parseClient = ParseClient.Instance;
            }
            else
            {
                this.parseClient = parseClient;
            }

            if (parseLiveQueryClient == null)
            {
                this.parseLiveQueryClient = ParseLiveQueryClient.Instance;
            }
            else
            {
                this.parseLiveQueryClient = parseLiveQueryClient;
            }

            Lifecycle.OnUnityQuit += Destroy;

            Lifecycle.OnUnityFocus += OnFocusChanged;

            // Setup the query
            SetupQuery();
        }
 public WebSocketClientCallback(ParseLiveQueryClient client)
 {
     _client = client;
 }
 public void Publicize()
 {
     Instance = this;
 }