Beispiel #1
0
    public static IEnumerator Push(string name, string content)
    {
        IFirebase pushed = firebase.Push();

        pushed.Child("IP").SetValue(Network.player.ipAddress);
        pushed.Child("name").SetValue(name);
        pushed.Child("content").SetValue(content);
        pushed.Child("time").SetValue(DateTime.Now.ToString());
        yield return(null);
    }
Beispiel #2
0
        public void Enqueue(T job)
        {
            QueueItem <T> item = new QueueItem <T>
            {
                Data      = job,
                Timestamp = ServerValue.TIMESTAMP,
            };

            IFirebase path = _jobs.Push();

            path.Set(item);
        }
Beispiel #3
0
 private void getEnemyId()
 {
     //have BATTLE ID first
     FireBase_battle = Firebase.CreateNew(FIRE_BASE_HOST + "battle/" + BATTLE_ID);
     FireBase_battle.Push().SetValue(playerId);
     battlePlayerChildAddedEventHandler = (object sender, ChangedEventArgs e) =>
     {
         IDataSnapshot dataSnap = e.DataSnapshot;
         Logger.gameControl("FireBase_battle ChildAdded {0}, {1}", dataSnap.Key, dataSnap.StringValue);
         if (!playerId.Equals(dataSnap.StringValue))
         {
             enemyId       = dataSnap.StringValue;
             gotoStartGame = true;
             //Loom.QueueOnMainThread(() =>
             //{
             //    gameStart();
             //});
             FireBase_battle.ChildAdded -= battlePlayerChildAddedEventHandler;
         }
     };
     FireBase_battle.ChildAdded += battlePlayerChildAddedEventHandler;
 }
Beispiel #4
0
    private void getPlayer_Battle_EnemyId()
    {
        FireBase_battlelist = Firebase.CreateNew(FIRE_BASE_HOST + BATTLE_LIST);
        playerId            = System.Guid.NewGuid().ToString();
        //IFirebase FireBase_battle = FireBase_battlelist.Push();
        //battleId = FireBase_battle.Key;

        Logger.gameControl("getPlayer_Battle_EnemyId playerId {0}, battleId {1}", playerId, BATTLE_ID);
        FireBase_battlelist.ChildAdded += (object sender, ChangedEventArgs e) =>
        {
            IDataSnapshot dataSnap = e.DataSnapshot;
            Logger.gameControl("FireBase_battlelist ChildAdded {0}, {1}", dataSnap.Key, dataSnap.StringValue);
        };

        battlelistvalueUpdateEventHandler = (object sender, ChangedEventArgs e) =>
        {
            IDataSnapshot dataSnap = e.DataSnapshot;
            Logger.gameControl("FireBase_battlelist ValueUpdated {0}, {1}", dataSnap.Key, dataSnap.StringValue);
            try
            {
                Dictionary <string, object> dic = dataSnap.DictionaryValue;
                object temp         = null;
                bool   findBattleId = false;
                foreach (string battleId in dic.Keys)
                {
                    if (battleId.Contains("skip"))
                    {
                        continue;
                    }
                    //dic.TryGetValue(battleId, out temp);
                    string status = dataSnap.Child(battleId).Child(BATTLE_STATUS).StringValue;
                    Logger.gameControl("FireBase_battlelist ValueUpdated {0}, {1}", battleId, status);
                    if (BATTLE_STATUS_WAITING.Equals(status))
                    {
                        dataSnap.Child(battleId).Ref.Child(playerId).SetValue(playerId);
                        dataSnap.Child(battleId).Child(BATTLE_STATUS).Ref.SetValue(BATTLE_STATUS_FIGHTING);
                        BATTLE_ID    = battleId;
                        findBattleId = true;
                        break;
                    }
                    //Dictionary<string, object> battlevalue = (Dictionary<string, object>)temp;
                    //object temp2 = null;
                    //foreach (string battleinfo in battlevalue.Keys)
                    //{
                    //    if ("status".Equals(battleinfo))
                    //    {
                    //        battlevalue.TryGetValue(battleId, out temp2);
                    //    }
                    //}
                }

                if (!findBattleId)
                {
                    IFirebase ref_battle = FireBase_battlelist.Push();
                    BATTLE_ID = ref_battle.Key;
                    ref_battle.Child(playerId).SetValue(playerId);
                    ref_battle.Child(BATTLE_STATUS).SetValue(BATTLE_STATUS_WAITING);
                }

                FireBase_battlelist.ValueUpdated -= battlelistvalueUpdateEventHandler;
                getEnemyId();
            }
            catch (Exception ex)
            {
                Debug.Log(ex.Message);
            }
        };

        FireBase_battlelist.ValueUpdated += battlelistvalueUpdateEventHandler;

        FireBase_battlelist.ChildChanged += (object sender, ChangedEventArgs e) =>
        {
            IDataSnapshot dataSnap = e.DataSnapshot;
            Logger.gameControl("FireBase_battlelist ChildChanged {0}, {1}", dataSnap.Key, dataSnap.StringValue);
        };
    }
Beispiel #5
0
 public static void InsertPainting(Painting painting)
 {
     Data.Push(JsonConvert.SerializeObject(painting));
 }