void ChildEventListen(ChildEventHandler eventHandler) { RequestHelper req = new RequestHelper { Headers = new Dictionary <string, string> { { "Accept", "text/event-stream" } }, Uri = FirebaseConfig.endpoint + path + ".json" + GetAuthParam(), DownloadHandler = eventHandler, Retries = int.MaxValue, RetrySecondsDelay = 1 }; //create an unsubscriber for events var unsubscriberGO = GameObject.Find("FirebaseRestUnsubscriber"); if (unsubscriberGO == null) { unsubscriberGO = new GameObject("FirebaseRestUnsubscriber"); unsubscriberGO.AddComponent <EventUnsubscriber>().requestHelper = req; MonoBehaviour.DontDestroyOnLoad(unsubscriberGO); } //Error handling are being handled internally RESTHelper.Get(req, err => RequestErrorHelper.ToDictionary(err).ToList().ForEach(x => Debug.LogError(x.Key + " - " + x.Value))); }
/// <summary> /// Combination of both ChildAdded and ChildRemoved. /// </summary> /// <param name="callback"></param> public void ChildChanged(Action <ChildEventArgs> callback, bool shallow = false) { ChildEventHandler childEventHandler = new ChildEventHandler(); childEventHandler.OnChildEventReceived += callback; childEventHandler.childEventType = ChildEventHandler.ChildEventType.ChildChanged; childEventHandler.shallow = shallow; ChildEventListen(childEventHandler); }