public JobQueue(IFirebase jobs, Func <T, bool> callback) { // create our own copy and ignore filters _jobs = jobs.Child("/"); _query = _jobs .On("child_changed", (snap, child, context) => { if (snap.Exists) { if (snap["Timestamp"][".sv"].Exists) { // local version return; } T data = snap["Data"].Value <T>(); try { if (callback(data)) { // remove from the queue snap.Ref().Remove(); } } catch (Exception ex) { Debug.WriteLine("ERROR: {0}", ex); } } }); }
protected IFirebase _playerRef; //This object firebase reference only in case of player (the only one who writes) /// <summary> /// Initialise properties. If this is the player, mark it and tag it as player /// </summary> public void Start() { _isPlayer = identifier == NetworkManager.identifier; if (_isPlayer && identifier != null) { _playerRef = NetworkManager.firebase.Child (identifier); gameObject.tag = "Player"; } }
//Init Firebase API public void Start () { Debug.Log("DBQueries-Line 16: Start called"); myFirebase = new FirebaseUnity.FirebaseAPI(); firebase= Firebase.CreateNew("https://popping-fire-7321.firebaseio.com/"); myFirebase.initialize("https://popping-fire-7321.firebaseio.com/"); customDeserializer = new CustomDeserializer(); }
public static void setBattleEventValue(IFirebase refFirebase, RemoteEventBase theEvent) { Dictionary <string, object> currentlocatoin = new Dictionary <string, object>(); currentlocatoin.Add(RemoteEventBase.KEY_VECTOR_X, theEvent.getCurrentLocation().x); currentlocatoin.Add(RemoteEventBase.KEY_VECTOR_Y, theEvent.getCurrentLocation().y); currentlocatoin.Add(RemoteEventBase.KEY_VECTOR_Z, theEvent.getCurrentLocation().z); Dictionary <string, object> targetlocation = new Dictionary <string, object>(); targetlocation.Add(RemoteEventBase.KEY_VECTOR_X, theEvent.getTargetLocation().x); targetlocation.Add(RemoteEventBase.KEY_VECTOR_Y, theEvent.getTargetLocation().y); targetlocation.Add(RemoteEventBase.KEY_VECTOR_Z, theEvent.getTargetLocation().z); Dictionary <string, object> value = new Dictionary <string, object>(); value.Add(RemoteEventBase.KEY_ACTION_NAME, theEvent.getActionName()); value.Add(RemoteEventBase.KEY_ACTOR, theEvent.getActorId()); value.Add(RemoteEventBase.KEY_ACT_TARGET, theEvent.getActTarget()); value.Add(RemoteEventBase.KEY_PLAYER_ID, theEvent.getPlayerId()); value.Add(RemoteEventBase.KEY_LOC_CURRENT, currentlocatoin); value.Add(RemoteEventBase.KEY_LOC_TARGET, targetlocation); value.Add(RemoteEventBase.KEY_TIME_STAMP, theEvent.getTimeStamp()); refFirebase.Child(RemoteEventBase.KEY_EVENT_ROOT).Push().SetValue(value); }
// Use this for initialization void Start() { fbRootRef = Firebase.CreateNew("https://" + AppConstants.kFirebaseAppID); primaryRef = fbRootRef.Child("FirstRoom"); //primaryRef.ChildAdded += primaryRefChildAdded; //primaryRef.ValueUpdated += primaryRefValueUpdated; }
//Init Firebase API public void Start() { Debug.Log("DBQueries-Line 16: Start called"); myFirebase = new FirebaseUnity.FirebaseAPI(); firebase = Firebase.CreateNew("https://popping-fire-7321.firebaseio.com/"); myFirebase.initialize("https://popping-fire-7321.firebaseio.com/"); customDeserializer = new CustomDeserializer(); }
public void resetLeaderboardOnFirebase() { for (int i = 1; i <= 10; i++) { IFirebase entry = root.Child(i.ToString()); entry.Child("Name").SetValue("AAAAAAAAAA"); entry.Child("Score").SetValue("0"); } }
protected IFirebase _playerRef; //This object firebase reference only in case of player (the only one who writes) /// <summary> /// Initialise properties. If this is the player, mark it and tag it as player /// </summary> public void Start() { _isPlayer = identifier == NetworkManager.identifier; if (_isPlayer && identifier != null) { _playerRef = NetworkManager.firebase.Child(identifier); gameObject.tag = "Player"; } }
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); }
public static IFirebase CreateNew(string path) { foreach (IFirebaseFactory factory in firebasePlatforms) { IFirebase firebase = factory.TryCreate(path); if (firebase != null) { return(firebase); } } return(null); }
public void Enqueue(T job) { QueueItem <T> item = new QueueItem <T> { Data = job, Timestamp = ServerValue.TIMESTAMP, }; IFirebase path = _jobs.Push(); path.Set(item); }
public void leaderboardEntriesToFirebase(LeaderboardEntry[] entriesTemp) { for (int i = 0; i < 9; i++) { IFirebase entry = root.Child((i + 1).ToString()); entry.Child("Name").SetValue(entriesTemp[i].name); entry.Child("Score").SetValue(entriesTemp[i].score.ToString()); leaderboardEntries [i].name = entriesTemp [i].name; leaderboardEntries [i].score = entriesTemp [i].score; } }
private IFirebase createFeatures(FirebaseType type) { IFirebase feature = null; switch (type) { case FirebaseType.CloudMessage: feature = new CloudMessaging(); registerCloudMessage(feature as CloudMessaging); break; } feature.Init(); return(feature); }
/// <summary> /// Initialise this player /// </summary> void Start () { //Initialise this object in map Vector3 initialPosition = new Vector3 (UnityEngine.Random.Range (-10, 10), 5, (UnityEngine.Random.Range (-10, 10))); firebase = Firebase.CreateNew ("https://gdg2015.firebaseio.com/"); firebase.UnAuth (); firebase.AuthAnonymously ((AuthData auth) => { InitFirebasePlayer(auth.Uid,initialPosition); }, (FirebaseError e) => { Debug.Log ("auth failure!! "+e); }); //Listeners firebase.ChildAdded += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Add(e.DataSnapshot)); }); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Remove(e.DataSnapshot)); }); }; firebase.ValueUpdated += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Modify(e.DataSnapshot)); }); }; }
void Awake() { if (singleton != null) { Destroy(singleton.gameObject); } singleton = this as MainManager; firebase_root = Firebase.CreateNew(FIREBASE_URL); firebase_users = firebase_root.Child("users"); user_id = ""; //print("firebase_users: " + firebase_users); //firebase_users.Child("bob123").SetValue("test!"); //print("key: " + firebase_users.Key); }
/// <summary> /// Initialise this player /// </summary> void Start() { //Initialise this object in map Vector3 initialPosition = new Vector3(UnityEngine.Random.Range(-10, 10), 5, (UnityEngine.Random.Range(-10, 10))); firebase = Firebase.CreateNew("https://gdg2015.firebaseio.com/"); firebase.UnAuth(); firebase.AuthAnonymously((AuthData auth) => { InitFirebasePlayer(auth.Uid, initialPosition); }, (FirebaseError e) => { Debug.Log("auth failure!! " + e); }); //Listeners firebase.ChildAdded += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Add(e.DataSnapshot)); }); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Remove(e.DataSnapshot)); }); }; firebase.ValueUpdated += (object sender, ChangedEventArgs e) => { ExecuteOnMainThread.Enqueue(() => { StartCoroutine(Modify(e.DataSnapshot)); }); }; }
// Use this for initialization void Start () { firebase = Firebase.CreateNew ("https://incandescent-torch-2575.firebaseio.com/testing"); firebase.AuthWithPassword ("*****@*****.**", "password", (AuthData auth) => { Debug.Log ("auth success!!" + auth.Uid); }, (FirebaseError e) => { Debug.Log ("auth failure!!"); }); firebase.ChildAdded += (object sender, ChangedEventArgs e) => { Debug.Log ("Child added!"); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { Debug.Log ("Child removed!"); }; //firebase.SetValue ("working?"); }
// Use this for initialization void Start() { firebase = Firebase.CreateNew("https://incandescent-torch-2575.firebaseio.com/testing"); firebase.AuthWithPassword("*****@*****.**", "password", (AuthData auth) => { Debug.Log("auth success!!" + auth.Uid); }, (FirebaseError e) => { Debug.Log("auth failure!!"); }); firebase.ChildAdded += (object sender, ChangedEventArgs e) => { Debug.Log("Child added!"); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { Debug.Log("Child removed!"); }; //firebase.SetValue ("working?"); }
public IFirebase Save(IFirebaseApp app) { if (this.Key != null && this.Key != "") { //remove old version first (not very pretty but Firebase change events are pain in tha butt) var entity = app.Child(this.Path + "/" + this.Key); entity.Remove(); } else { this.CreatedAt = DateTime.Now; } var newEntity = app.Child(this.Path); this.UpdatedAt = DateTime.Now; this.Revision = Guid.NewGuid().ToString(); IFirebase result = newEntity.Push(this); this.Key = result.Key; return(result); }
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; }
// Use this for initialization void Start() { Debug.Log("TestScript start+"); firebase = Firebase.CreateNew("https://boiling-torch-7529.firebaseio.com/test"); //firebase.AuthWithPassword("*****@*****.**", "iloveawei", (AuthData auth) => //{ // Debug.Log("auth success!!" + auth.Uid); //}, (FirebaseError e) => //{ // Debug.Log("auth failure!!"); //}); firebase.ChildAdded += (object sender, ChangedEventArgs e) => { Debug.Log("Child added!"); }; firebase.ChildRemoved += (object sender, ChangedEventArgs e) => { Debug.Log("Child removed!"); }; firebase.SetValue("working? no auth"); Debug.Log("TestScript start-"); }
/// <summary> /// Set firebase /// </summary> void Awake() { firebase = Firebase.CreateNew ("https://godcube.firebaseio.com/"); }
public SetColorViewModel(INavigationService navigationService, IDialog dialogService, IFirebase databaseService) : base(navigationService, dialogService, databaseService) { Colors = new ObservableCollection <NamedColor>(); var colors = NamedColor.All; foreach (var color in colors) { Colors.Add(color); } ConfirmColorCommand = new Command <NamedColor>(async(parameter) => await ConfirmColorAsync(parameter)); }
public SetCategoryViewModel(INavigationService navigationService, IDialog dialogService, IFirebase databaseService) : base(navigationService, dialogService, databaseService) { DeletedStates = new List <StateModel>(); SetCommands(); }
public ItemsViewModel(INavigationService navigationService, IDialog dialogService, IFirebase databaseService) : base(navigationService, dialogService, databaseService) { UpdateModelCommand = new Command(async() => await UpdateModelAsync()); SetEditItemCommand = new Command <ItemModel>((parameter) => SetEditItem(parameter)); CreateItemCommand = new Command(execute: async() => await CreateItemAsync()); SaveItemCommand = new Command(execute: async() => await SaveItemAsync()); ResetNewItemCommand = new Command(ResetNewItem); ResetSearchItemCommand = new Command(ResetSearchItem); ShowItemsCommand = new Command(async() => await ShowItemsAsync()); LoadMoreCommand = new Command(execute: async() => await LoadMoreAsync()); SetItemNameCommand = new Command <ItemModel>(execute: async(parameter) => await SetItemNameAsync(parameter)); CategorySettingsCommand = new Command(async() => await OpenCategorySettingsAsync()); ResetPanelItemsCommand = new Command(ResetPanelItems); }
static RealTimeChat() { firebase = Firebase.CreateNew(FIREBASE_URL).Child(FIREBASE_CHILD); firebase.ValueUpdated += OnValueUpdated; firebase.Error += OnError; }
// Use this for initialization private void gameStart() { Debug.Log("GameController start+"); _gameProcessing = true; controlUIPanelHost.SetActive(true); unitControlPanels = controlUIPanelHost.GetComponentsInChildren <UnitControlPanel>(); createHumanoid(); FireBase_battle_event = FireBase_battle.Child(RemoteEventBase.KEY_EVENT_ROOT); ////firebase.AuthWithPassword("*****@*****.**", "iloveawei", (AuthData auth) => ////{ //// Debug.Log("auth success!!" + auth.Uid); ////}, (FirebaseError e) => ////{ //// Debug.Log("auth failure!!"); ////}); FireBase_battle_event.ChildAdded += (object sender, ChangedEventArgs e) => { IDataSnapshot dataSnap = e.DataSnapshot; Logger.firebase("Child added! " + sender + ", " + e + ", " + dataSnap.Key); try { List <RemoteEventBase> result = FireBaseUtil.getBattleEventValue(dataSnap); onRemoteEvents(result); } catch (Exception ex) { Debug.Log(ex.Message); } // ////String x = dataSnap.Child("x").StringValue; // ////String y = dataSnap.Child("y").StringValue; // ////String z = dataSnap.Child("z").StringValue; // //Dictionary<string, object> value = dataSnap.DictionaryValue; // //string x = value["x"].ToString(); // //string y = value["y"].ToString(); // //string z = value["z"].ToString(); // //if (debugFirebase) // // Debug.Log("Child added! " + dataSnap.Key + ", s " + dataSnap.DictionaryValue + ", x " + x + ", y " + y + ", z " + z); // //Vector3 p = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z)); // //foreach (Humanoid h in humanoid) // //{ // // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); // //}; }; //firebase.ChildRemoved += (object sender, ChangedEventArgs e) => //{ // IDataSnapshot dataSnap = e.DataSnapshot; // if (debugFirebase) // Debug.Log("Child removed! " + sender + ", " + e + ", " + dataSnap); //}; FireBase_battle_event.ValueUpdated += (object sender, ChangedEventArgs ex) => { IDataSnapshot dataSnap = ex.DataSnapshot; Logger.firebase("Child ValueUpdated! " + sender + ", " + ex + ", " + dataSnap.Key); // //String x = dataSnap.Child("x").StringValue; // //String y = dataSnap.Child("y").StringValue; // //String z = dataSnap.Child("z").StringValue; // //Debug.Log("Child ValueUpdated! " + dataSnap.Key + ", " + dataSnap.StringValue + ", " + x + ", " + y + ", " + z); // //Vector3 p = new Vector3(x, y, z); // //foreach (Humanoid h in humanoid) // //{ // // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); // //}; // //try // //{ // // Dictionary<string, object> value = dataSnap.DictionaryValue; // // string x = value["x"].ToString(); // // string y = value["y"].ToString(); // // string z = value["z"].ToString(); // // Debug.Log("Child ValueUpdated! " + dataSnap.Key + ", s " + dataSnap.DictionaryValue + ", x " + x + ", y " + y + ", z " + z); // // Vector3 p = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z)); // // foreach (Humanoid h in humanoid) // // { // // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); // // }; // //} // //catch (Exception exx) { // // Debug.Log(exx.ToString()); // //} }; FireBase_battle_event.ChildChanged += (object sender, ChangedEventArgs e) => { //firebase.Child(enemyId.ToString()).ChildChanged += (object sender, ChangedEventArgs e) => { IDataSnapshot dataSnap = e.DataSnapshot; Logger.firebase("Child ChildChanged! " + sender + ", " + e + ", " + dataSnap.Key); //String x = dataSnap.Child("x").StringValue; //String y = dataSnap.Child("y").StringValue; //String z = dataSnap.Child("z").StringValue; //Debug.Log("Child ChildChanged! " + dataSnap.Key + ", " + x + ", " + y + ", " + z); //Vector3 p = new Vector3(float.Parse(x), float.Parse(y), float.Parse(z)); //foreach (Humanoid h in humanoid) //{ // h.onRemoteUpdate(Int32.Parse(dataSnap.Key), p); //}; /* * try * { * List<JsonBaseUnit> result = JsonBaseUnit.getFirebaseValue(dataSnap); * foreach (Humanoid h in humanoid) * { * foreach (JsonBaseUnit json in result) * { * h.onRemoteUpdate(json); * } * } * } * catch (Exception ex) * { * Debug.Log(ex.ToString()); * }*/ }; //firebase.ChildChanged += (object sender, ChangedEventArgs e) => { //firebase.Child(playerId.ToString()).Child("attack").ChildChanged += (object sender, ChangedEventArgs e) => { //IDataSnapshot dataSnap = e.DataSnapshot; //if (debugFirebase) // Debug.Log("attack ChildChanged! " + sender + ", " + e + ", " + dataSnap.Key); /* try * { * List<JsonBaseAttack> result = JsonBaseAttack.getFirebaseValue(dataSnap); * foreach (Humanoid h in humanoid) * { * foreach (JsonBaseAttack json in result) * { * //h.onRemoteUpdate(json.getId(), json.getVector3()); * } * } * } * catch (Exception ex) * { * Debug.Log(ex.ToString()); * }*/ //}; FireBase_battle.SetValue("GameStart!"); //Dictionary<string, object> value = new Dictionary<string, object>(); //Dictionary<string, object> location = new Dictionary<string, object>(); //location.Add("x", "9"); //location.Add("y", "9"); //location.Add("z", "999"); //value.Add("action", "move"); //value.Add("action_unit_id", "123"); //value.Add("current_location", location); //firebase.Child("FightLog").Push().SetValue(value); //value.Add("target_location", location); //firebase.Child("FightLog").Push().SetValue(value); Debug.Log("GameController start-"); }
public void initialize(string url) { firebase = Firebase.CreateNew(base_url); this.base_url = url; }
public void Delete(Children model) { firebase = new Irrigation(); firebase.Delete(model.child1, model.child2, model.child3); }
public void Add(HumidityData model) { firebase = new Irrigation(); firebase.Post(model.data, model.status); }
public CategoriesViewModel(INavigationService navigationService, IDialog dialogService, IFirebase databaseService) : base(navigationService, dialogService, databaseService) { RefreshCategoriesCommand = new Command(async() => await RefreshCategoriesAsync()); LoadMoreCategoriesCommand = new Command(async() => await LoadMoreCategoriesAsync()); CreateCategoryCommand = new Command(async() => await CreateCategoryAsync()); OpenCategoryCommand = new Command <CategoryModel>(async(param) => await OpenCategoryAsync(param)); RefreshCategoriesCommand.Execute(null); }
public void Put(PutHumidityData model) { firebase = new Irrigation(); firebase.Put(model.children.child1, model.children.child2, model.children.child3, model.humidity.data, model.humidity.status); }
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); }; }
public SpaController(IFirebase firebase) { _firebase = firebase; }
public BaseViewModel(INavigationService navigationService, IDialog dialogService, IFirebase firebaseService) { NavigationService = navigationService; DialogService = dialogService; FirebaseService = firebaseService; }