public void SetParam <T> (string objectName, T myObject)
    {
        string rpcKey = reference.Child(MyConst.GAMEROOM_ROOM).Child(gameRoomKey).Child(MyConst.GAMEROOM_RPC).Push().Key;

        Dictionary <string, System.Object> result = new Dictionary <string, System.Object> ();

        result [MyConst.RPC_DATA_USERHOME] = GameManager.isHost;


        Dictionary <string, System.Object> jsonResult = new Dictionary <string, System.Object> ();

        jsonResult [objectName]         = JsonUtility.ToJson(myObject);
        result [MyConst.RPC_DATA_PARAM] = jsonResult;


        string directory = "/" + MyConst.GAMEROOM_ROOM + "/" + gameRoomKey + "/" + MyConst.GAMEROOM_RPC + "/" + rpcKey;

        FirebaseDBFacade.CreateTableChildrenAsync(directory, reference, result);
    }
    public void UpdateBattleStatus(string stateName, int stateCount, string playerParam = "", string enemyParam = "")
    {
        Dictionary <string, System.Object> entryValues = new Dictionary <string, System.Object> ();

        entryValues.Add(MyConst.BATTLE_STATUS_STATE, stateName);
        entryValues.Add(MyConst.BATTLE_STATUS_COUNT, stateCount.ToString());
        if (!string.IsNullOrEmpty(playerParam))
        {
            entryValues.Add(MyConst.RPC_DATA_PLAYER_ANSWER_PARAM, playerParam);
        }

        if (!string.IsNullOrEmpty(enemyParam))
        {
            entryValues.Add(MyConst.RPC_DATA_ENEMY_ANSWER_PARAM, enemyParam);
        }

        battleStatusKey = reference.Child(MyConst.GAMEROOM_ROOM).Child(gameRoomKey).Child(MyConst.GAMEROOM_BATTLE_STATUS).Push().Key;
        string directory = "/" + MyConst.GAMEROOM_ROOM + "/" + gameRoomKey + "/" + MyConst.GAMEROOM_BATTLE_STATUS + "/" + battleStatusKey + "/";

        FirebaseDBFacade.CreateTableChildrenAsync(directory, reference, entryValues);
    }
    private void RoomCreateJoin(bool isHost, string userPlace)
    {
        GameManager.isHost = isHost;
        RPCListener();

        Dictionary <string, System.Object> result = new Dictionary <string, System.Object> ();

        result [MyConst.RPC_DATA_PLAYER] = JsonUtility.ToJson(MyConst.player);
        Dictionary <string, System.Object> entryValues = result;

        string directory = MyConst.GAMEROOM_ROOM + "/" + gameRoomKey + "/" + MyConst.GAMEROOM_INITITAL_STATE + "/" + userPlace + "/" + MyConst.RPC_DATA_PARAM + "/";

        FirebaseDBFacade.CreateTableChildrenAsync(directory, reference, entryValues);

        //set room status to open when create room
        if (isHost)
        {
            FirebaseDBFacade.SetTableValueAsync(reference.Child(MyConst.GAMEROOM_ROOM).Child(gameRoomKey).Child(MyConst.GAMEROOM_STATUS), "0");
        }
        //set battle status to answer when start of game
        CheckInitialPhase();

        InitialStateListener();
    }