Beispiel #1
0
        public JobQueue(IFirebase jobs, Func <T, bool> callback)
        {
            // create our own copy and ignore filters
            _jobs = jobs.Child("/");

            _query = _jobs
                     .On("child_changed", (snap, child, context) =>
            {
                if (snap.Exists)
                {
                    if (snap["Timestamp"][".sv"].Exists)
                    {
                        // local version
                        return;
                    }

                    T data = snap["Data"].Value <T>();

                    try
                    {
                        if (callback(data))
                        {
                            // remove from the queue
                            snap.Ref().Remove();
                        }
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine("ERROR: {0}", ex);
                    }
                }
            });
        }