internal FireNode(string p, string o)
 {
     pid      = p;
     oid      = o;
     dataFire = FirebaseManager.getDBRef().Child(pid).Child(oid);
     dataFire.addValueChanged(onValueChanged);
 }
 public virtual void OnDestroy()
 {
     if (!_appQuited && FirebaseManager.getInstance() != null && !FirebaseManager.getInstance().keepOnDestoryObj)
     {
         removeMe();
     }
 }
        internal override FireNode genChild(DBResult ds)
        {
            RemoteData rd = parseRemoteData(ds);

            if (rd == null)
            {
                return(null);
            }
            FireNode   fn = new FireNode(pid, ds.key());
            GameObject go = null;

            if (FirePlayerQueuer.KEY_TAG.Equals(rd.tag))
            {
                go = FirebaseManager.getInstance().playerQueuer.gameObject;
            }
            else
            {
                FireRepo.Handler h = FirebaseManager.getRepo().handler;
                go = h.onDataInit(pid, ds.key(), fn, rd);
            }
            InitBundle ib = new InitBundle(fn, rd);

            go.SendMessage("initAtFire", ib, SendMessageOptions.DontRequireReceiver);
            return(fn);
        }
Exemple #4
0
 public static FirebaseManager getInstance()
 {
     if (instance == null)
     {
         instance = FindObjectOfType <FirebaseManager>();
     }
     return(instance);
 }
        public void addPlayer(string id)
        {
            DateTime d = NistService.getTime();

            data.intoMap.Add(id, d);
            node.dataFire.Child("intoMap").Child(id).SetValueAsync(d.ToString("o"));
            node.dataFire.Child("sid").SetValueAsync(FirebaseManager.getMePid());
        }
        internal void post(RemoteData o, Action <bool, object> cb = null)
        {
            o.pid = pid;
            o.oid = oid;
            o.sid = FirebaseManager.getMePid();
            string s = JsonConvert.SerializeObject(o);

            dataFire.SetRawJsonValueAsync(s, cb);
        }
 public void removeMe()
 {
     if (!removed)
     {
         removed = true;
         dataFire.removeValueChanged(onValueChanged);
         dataFire.removeMe();
         FirebaseManager.getRepo().remove(pid, oid);
         onRemoveAction();
     }
 }
 public void init(string p, string o)
 {
     if (node != null)
     {
         return;
     }
     pid  = p;
     oid  = o;
     node = FirebaseManager.getRepo().get(pid, oid);
     node.addValueChangedListener(onValueChanged);
     node.changePostFunc = (onNotifyChangePost);
 }
 public void init(bool createData, Action cb)
 {
     FirebaseManager.getInstance().addInitedAction(b => {
         init(KEY_PID, KEY_OID);
         ceneter.addPlayer(meId);
         if (createData)
         {
             postData((bb, o) => { cb(); });
         }
         else
         {
             node.initCallback.add(cb);
         }
         node.dataFire.Child("intoMap").addChildRemoved(onPlayerLeave);
     });
 }
        private void onValueChanged(DBResult ea)
        {
            string s = ea.getRawJsonValue();

            if (!string.IsNullOrEmpty(s))
            {
                RemoteData rd = JsonConvert.DeserializeObject <RemoteData>(s);
                rd.setSource(s);
                if (!string.Equals(rd.sid, FirebaseManager.getMePid()))
                {
                    valueChangedListeners.ForEach(l => {
                        l(rd);
                    });
                }
            }
            initCallback.done();
        }
 internal static bool hasToke()
 {
     return(string.Equals(FirebaseManager.getMePid(), PlayerQueuer.instance.getTokenPlayer()));
 }
Exemple #12
0
 internal PlayerMap() : base(FirebaseManager.getDBRef())
 {
 }
 public ObjMap(string pid) : base(FirebaseManager.getDBRef().Child(pid))
 {
     this.pid = pid;
 }