Пример #1
0
        /// <summary>
        /// Fetch data from Firebase. Calls OnGetSuccess on success, OnGetFailed on failed.
        /// OnGetSuccess action contains the corresponding Firebase and the fetched Snapshot
        /// OnGetFailed action contains the error exception
        /// </summary>
        /// <param name="param">REST call parameters on a string. Example: &quot;orderBy=&#92;"$key&#92;"&quot;print=pretty&quot;shallow=true"></param>
        /// <returns></returns>
        public void GetValue(string param = "")
        {
            try
            {
                if (Credential != "")
                {
                    param = (new FirebaseParam(param).Auth(Credential)).Parameter;
                }

                string url = Endpoint;

                param = WWW.EscapeURL(param);

                if (param != "")
                {
                    url += "?" + param;
                }

                root.StartCoroutine(RequestCoroutine(url, null, null, OnGetSuccess, OnGetFailed));
            }
            catch (WebException webEx)
            {
                if (OnGetFailed != null)
                {
                    OnGetFailed(this, FirebaseError.Create(webEx));
                }
            }
            catch (Exception ex)
            {
                if (OnGetFailed != null)
                {
                    OnGetFailed(this, new FirebaseError(ex.Message));
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Fetch data from Firebase. Calls OnGetSuccess on success, OnGetFailed on failed.
        /// OnGetSuccess action contains the corresponding Firebase and the fetched Snapshot
        /// OnGetFailed action contains the error exception
        /// </summary>
        /// <param name="query">REST call parameters wrapped in FirebaseQuery class</param>
        /// <returns></returns>
        public void GetValue(FirebaseParam query)
        {
            try
            {
                if (Credential != "")
                {
                    query = new FirebaseParam(query).Auth(Credential);
                }

                string url = Endpoint;

#pragma warning disable CS0618 // Type or member is obsolete
                string param = WWW.EscapeURL(query.Parameter);
#pragma warning restore CS0618 // Type or member is obsolete

                if (param != "")
                {
                    url += "?" + param;
                }

                root.StartCoroutine(RequestCoroutine(url, null, query.HttpHeader, OnGetSuccess, OnGetFailed));
            }
            catch (WebException webEx)
            {
                if (OnGetFailed != null)
                {
                    OnGetFailed(this, FirebaseError.Create(webEx));
                }
            }
            catch (Exception ex)
            {
                if (OnGetFailed != null)
                {
                    OnGetFailed(this, new FirebaseError(ex.Message));
                }
            }
        }