/* * This code ain't mine homie. * Code Adapted from: https://medium.com/@rotolonico/firebase-database-in-unity-with-rest-api-42f2cf6a2bbf * Code Author: Domenico Rotolo * Code Accessed on: 21/09/2019 */ //this method is used to pull the comments from firebase //it takes the callback method as a parameter public void LoadComments(GetUsersCallback callback) { //database call RestClient.Get(databaseURL + "/" + locationName + ".json?auth=" + idToken).Then(response => { //recieve the contents of the db call as a json var responseJson = response.Text; //parse the data var data = fsJsonParser.Parse(responseJson); //create new object to hold the deserialized data object deserialized = null; //try to deserialize the data following the dictionary definition + the data defintion of the MarkerCommentClass, referencing the data into the //deserialized object serializer.TryDeserialize(data, typeof(Dictionary <string, MarkerCommentClass>), ref deserialized); //store data as a dictionary var users = deserialized as Dictionary <string, MarkerCommentClass>; //this is used to actually create the dictionary callback(users); }); }
//Retrieve all user details /// <summary> /// Function which is used to retrieve all the user details from the database /// </summary> /// <param name="callback"></param> public static void GetUsers(GetUsersCallback callback) { RestClient.Get("https://engeenur-17baa.firebaseio.com/students.json").Then(response => { var responseJson = response.Text; var data = fsJsonParser.Parse(responseJson); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, UserData>), ref deserialized); var userDatas = deserialized as Dictionary <string, UserData>; callback(userDatas); }); }
public static void GetUsers(string level, GetUsersCallback callback) { RestClient.Get($"{databaseUrl}users/{level}.json").Then(response => { var responseJson = response.Text; var data = fsJsonParser.Parse(responseJson); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, User>), ref deserialized); var users = deserialized as Dictionary <string, User>; callback(users); }); }
public static void GetUsers(GetUsersCallback callback) { RestClient.Get($"{databaseURL}/users.json").Then(response => { var responseJson = response.Text; Debug.Log("Response: " + responseJson); //Using FullSerializer library to serialize a Dictionary datatype in this case var data = fsJsonParser.Parse(responseJson); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, User>), ref deserialized); var users = deserialized as Dictionary <string, User>; callback(users); }); }
/// <summary> /// Gets all users from the Firebase Database /// </summary> /// <param name="callback"> What to do after all users are downloaded successfully </param> public static void GetUsers(GetUsersCallback callback) { RestClient.Get($"{databaseURL}users.json").Then(response => { var responseJson = response.Text; // Using the FullSerializer library: https://github.com/jacobdufault/fullserializer // to serialize more complex types (a Dictionary, in this case) var data = fsJsonParser.Parse(responseJson); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, User>), ref deserialized); var users = deserialized as Dictionary <string, User>; callback(users); }); }
/// <summary> /// Gets all users from the Firebase Database /// </summary> /// <param name="callback"> What to do after all users are downloaded successfully </param> public static void GetUsers(GetUsersCallback callback) { string idToken = PlayerPrefs.GetString("Current_idToken"); string doc_id = PlayerPrefs.GetString("Current_localId"); RestClient.Get($"{databaseURL}Patients/" + doc_id + ".json?auth=" + idToken).Then(response => { var responseJson = response.Text; // Using the FullSerializer library: https://github.com/jacobdufault/fullserializer // to serialize more complex types (a Dictionary, in this case) var data = fsJsonParser.Parse(responseJson); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, Patient>), ref deserialized); var users = deserialized as Dictionary <string, Patient>; callback(users); }); }
public static void GetCoordinates(GetUsersCallback callback) { RestClient.Get($"{databaseURL}/coordinates/dronelocation.json").Then(response => { var responseJson = response.Text; // Debug.Log("Response" + responseJson); var N = JSON.Parse(responseJson); targetX = N["x"].AsFloat; targetY = N["y"].AsFloat; targetZ = N["z"].AsFloat; // Debug.Log("X is: " + targetX ); //Using FullSerializer library to serialize a Dictionary datatype in this case var data = fsJsonParser.Parse(responseJson); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, User>), ref deserialized); var users = deserialized as Dictionary <string, User>; callback(users); }); }
/* * This code ain't mine homie. * Code Adapted from: https://medium.com/@rotolonico/firebase-database-in-unity-with-rest-api-42f2cf6a2bbf * Code Author: Domenico Rotolo * Code Accessed on: 21/09/2019 */ //this code is to load the comments from firebase for this location public void LoadComments(GetUsersCallback callback) { Debug.Log("Location Name:" + locationName); RestClient.Get(databaseURL + "/" + locationName + ".json?auth=" + idToken).Then(response => { var responseJson = response.Text; Debug.Log(responseJson); var data = fsJsonParser.Parse(responseJson); Debug.Log(data); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, MarkerCommentClass>), ref deserialized); var users = deserialized as Dictionary <string, MarkerCommentClass>; Debug.Log(users); Debug.Log("Right before the callback!"); callback(users); }); }
/// <summary> /// Gets all users from the Firebase Database /// </summary> /// <param name="callback"> What to do after all users are downloaded successfully </param> public static void GetUsers(GetUsersCallback callback) { string idToken = PlayerPrefs.GetString("Current_idToken"); string doc_id = PlayerPrefs.GetString("Current_localId"); RestClient.Get($"https://fyp-2020-smart-rehab.firebaseio.com/Appointments/" + doc_id + ".json?auth=" + idToken).Then(response => { var responseJson = response.Text; // Using the FullSerializer library: https://github.com/jacobdufault/fullserializer // to serialize more complex types (a Dictionary, in this case) var data = fsJsonParser.Parse(responseJson); object deserialized = null; serializer.TryDeserialize(data, typeof(Dictionary <string, Appointment>), ref deserialized); var users = deserialized as Dictionary <string, Appointment>; callback(users); }).Catch(error => { Debug.Log(error.Message); Debug.Log("Appointment Not Found"); }); }