DiscoverTenerife
|
the part of the class firebaseHandler that controls the downloading operations More...
Public Member Functions | |
void | downloadFriendData (string uid) |
this method tries to download the necesary information of the given user id. If it fails on the process it adds the user id to the friendDataDownloadQueue_ list. If it success it calls the addFriendData method of UserData class creating a new FriendData object. More... | |
void | readUserData () |
This method download all the information that is releated to the user from the firebase database. More... | |
void | downloadRankingPlayerData () |
This method downloads all the data what will be shown on the players ranking and store it as a RankingPlayerData object on the rankingData_ list. It changes the downloadingRankingData_ attribute to reflect the current state of the download. More... | |
bool | internetConnection () |
bool | FirebaseDependenciesAreResolved () |
void | CreateNewUser (string email, string password) |
bool | cooldownVisitingPlaceFinished (string type, int id) |
This method returns true if the place with the given type and id is ready for a new visit. The cooldown time is defined on the class gameRules, check that class for more information. More... | |
bool | cooldownVisitingStoredPlaceFinished (StoredPlace storedPlace) |
This method returns true if the place with the given type and id is ready for a new visit. The cooldown time is defined on the class gameRules, check that class for more information. More... | |
bool | cooldownVisitingPlaceByNameFinished (string name) |
This method returns true if the place with the given name is ready for a new visit. The cooldown time is defined on the class gameRules, check that class for more information. You have to be aware that its possible that two places has the same name, on that case, it will check only the first one. More... | |
void | userVisitedPlace (string type, int id, long timeOfTheVisit=-1) |
This method register a new visit for the place with the given type and id and the given timestamp, if the given timestamp is negative it will use the current timestamp. It also calls the writePlaceData and the writeUserData methods to upload the new visit information to the database. More... | |
void | userVisitedPlaceByName (string name, long timeOfTheVisit=-1) |
This method search on all the places the first one who match the given name, and then, it calls the userVisitedPlace method, check that method for more information. You have to be aware that if two places has the same name, the new visit will be added only to the first one. More... | |
bool | hasUserVisitPlaceByName (string name) |
This method search on the places that the current user has visited and check if there is at least one place with that name, on that case it returns true, it returns false in other case. More... | |
Place | askForAPlace () |
This method calls askForAPlace method of requestHandler and returns the place that that method returns. If you want more information check the requestHandler documentation. This method also instanciate a requestHandler if it doesnt exists when its called. More... | |
bool | placesAreReady () |
bool | userDataIsReady () |
void | sortPlaces () |
this method calls the sortPlaces method of the requestHandler class. Check that class documentation to get more information. More... | |
Dictionary< string, string > | findPlaceByName (string name) |
this method returns a dictionary that contains the id and the type of the place that has the given name. If there isn't any place with that name, it will return a dictionary that contains two entries id with the string "-1" and type with the string "noType". If there is more than one place with the given name, only the first one will be returned. More... | |
int | totalOfPlaces () |
getter of the quantity of places More... | |
int | totalOfPlacesOfZone (string zone) |
this method counts all the places that have the given zone name on their zone_ property. If there is no places on the given zone, it will show a message on the console and return a 0. The valid zones are determinated on the mapRulesHandler class, check its documentation for more information. More... | |
Dictionary< string, string > | getPlaceData (string type, string id) |
This method search on the property allPlaces_ if there is a place with the given type and id. If there isn't any place that match both the given id and the given type, it will return null. More... | |
void | SearchOtherUserByName (string toSearch, string type, SearchBar toAdvise=null) |
This method tries to find other user on the list of users that allow be found by other users on the different types of searchs. If a SearchBar object is given it will call the resultsOfTheSearch method of that class with a dictionary version of the found user. More... | |
void | sendFriendshipInvitation (string uidToInvite, SearchedPlayer searchedPlayerToAdvice) |
This method tries to send a new friendship invitation of the current user to the user that has the given id. The sending can produce three states: More... | |
void | askForNewPlaces () |
This method calls the updateStartIndex method of the requestHandler class to make the requestHandler choose new places. More... | |
void | addOtherUserScoreToUpload (Dictionary< string, string > uidAndScore) |
This method adds the given dictionary to the otherUserScoresToUpload_ list. More... | |
bool | isRankingDataComplete () |
This method returns true if all the data of the users that appeard on the ranking is already downloaded, false in other case. More... | |
bool | isDownloadingRankingDataNow () |
getter of the downloadingRankingData_ property. More... | |
RankingPlayerData | getRankingPlayerDataById (string uid) |
This method returns the RankingPlayerData object with the data of the player who has the given user id. It would return null if there isnt any player with that id. More... | |
List< RankingPlayerData > | getRankingPlayerData () |
Getter of the rankingData_ propery. More... | |
void | sortRankingDataList () |
This method sorts the users that appeard on the ranking. It sorts them setting on the firsts positions users with the highers scores. It also updates the top_ property of the RankingPlayerData objects of the lists using the setTop method. More... | |
void | LoginUser (string email, string password) |
void | AnonymousUser () |
void | SignInWithGoogle () |
This method will be called when the google signin button is pressed, it start the google authentication process calling the method OnAuthenticationFinished when it finish. More... | |
void | LogOut () |
void | writeNewPlaceOnDataBase (Place place, string type, int placeID) |
void | writePlaceData (string type, string id) |
This method uploads the data from the place that matches the given type and id. If the upload fails it adds the information of the place to placesToUploadQueue_. More... | |
void | updateUserDeleteAFriend (string noFriendUid, string deletedFriendsListInJSON) |
This method must be called when there is internet connection, otherwise it wont to nothing. This method upload the deletedFriends property of the user that has the given id. More... | |
void | uploadFriendChallengesOf (FriendData friendDataToUpload) |
this method upload the challengue list of the given user. More... | |
void | uploadSocialPreferences () |
this method should be called either when there is changes on the current user's social preferences or the last changes couldnt been uploaded on the past. It checks if there is any change on the three permision and upload to the firebase database the changes on the preferences. It checks if the three lists are uploaded, if one or more of them fails on the uploading, it puts the hasToUploadSocialPreferences_ property to true, so this method will be called again when the internet connection is ready. More... | |
void | updateUserAddedAFriend (string friendUid, string acceptedFriendsInvitationsListInJSON) |
This method tries to upload the accepted friendships invitations list of the given user. If it complete it succesfully, it removes the friendUid of the list of the user that need to be notified with the hasBeenNotified method. It also sets the uploadingNotifications_ property as true but when the try of updating finish, in any way, it sets the uploadingNotifications_ property as false. More... | |
void | writeAllFriendProperties () |
This method calls the writeFriendProperty with each element of the otherUsersPropertiesToUpload_ list and it removes the each of those elements taking care of that each of those elements could enter again on the list. That could happen if the upload goes wrong. More... | |
void | writeFriendProperty (string userId, string property, string json) |
This method downloads the current information of the given property of the given friend and then calls the correct method for taking care of differences between the cloud information and the local information. More... | |
void | writeAllUserProperties () |
This method calls writeSafeProperties with each safe property and writeUnsafeProperty with each unsafe property of the current user. It uses the getJSONof method of UserData class. More... | |
void | writeQueuedUserProperties () |
this method calls the writeSafeProperties or writeUnsafeProperty depending of the type of each element that is stored in currentUserPropertiesToUpload_ list. It removes the elements wich it calls those methods taking care of the fact that those properties could enter again on the currentUserPropertiesToUpload_ list if they fail on the upload. More... | |
void | writeSafeProperties (string property, string json) |
this method writes on the given property on the database the given json value. It doesnt take care of the version that is on the database. It simply overwrite it. If something goes wrong during the upload, it adds the property to currentUserPropertiesToUpload_ again. More... | |
void | writeUnsafeProperty (string property, string json) |
this method writes on the given property on the database the given json value. It takes care of the information that is currently on the database and tries to avoid incongruencies of the database. If something goes wrong during the uploading it adds again the property to the currentUserPropertiesToUpload_ list. More... | |
Public Attributes | |
UserData | currentUser_ = null |
requestHandler | requestHandler_ |
Static Public Attributes | |
static firebaseHandler | firebaseHandlerInstance_ = null |
Private Member Functions | |
void | downloadAllFriendData () |
this method calls the downloadFriendData method with each user id that is on the friendDataDownloadQueue_. More... | |
void | downloadAllNewfriendsInvitationsData () |
This method calls downloadNewFriendInvitationData method with each of the user ids that are on the new friends invitations list of the current user. More... | |
void | downloadNewFriendInvitationData (string uid) |
this method tries to download the display name and the list of newFriendsInvitations of the user that matches the given user id. If its fails it adds the user id to the newFriendDataDownloadQueue_ list and if its success, its calls the addNewFriendData method of UserData. More... | |
void | downloadAllPlaces () |
This method start as many coroutines as types of places are defined on mapRulesHandler. Each coroutine will download the information of that type of place. If you want more information check the mapRulesHandler documentation and the downloadOneTypeOfSite method of this class. More... | |
IEnumerator | downloadOneTypeOfSite (string typeSite) |
This coroutine tries to download all the places of the given type. If there is no internet connection it waits until there is avaible again. When all the places of all types has already downloaded it sets ON the placesReady_ flag. More... | |
void | downloadUsersPermissionsLists () |
This method download the lists of the user social permissions. They are usersThatAllowFriendshipInvitations, usersThatAllowBeChallenged and usersThatAllowAppearedOnRanking. The downloadingAnyOfTheUsersPermissionsLists_ is set as a true. The social permissions are downloaded in a parallel way for searching more efficiency if some of them failed the downloadingAnyOfTheUsersPermissionsLists_ property will be set as false again. More... | |
void | Awake () |
void | Update () |
void | CheckDependenciesFirebase (Task< DependencyStatus > task) |
void | OnApplicationQuit () |
This method is called when the application is closed, it saves all the offline information and stop the firebase online services. More... | |
void | OnDestroy () |
This method is called when the firebaseHandler object is destroyed. More... | |
void | OnSceneLoaded (Scene scene, LoadSceneMode mode) |
This method is called each time a scene is loaded, if placesReady_ variable is true, it calls the useStartIndex method of the requestHandler object, to allow keeping with same places. More... | |
void | uploadPlacesQueue () |
this method tries to upload all the information that is on the placesToUpdateQueue_ property. If it success, it erase the place from the list, but if its fails the writePlaceData will add again the place to the queue. More... | |
void | uploadOtherUserScores () |
This method tries to upload the information of the first element of otherUserScoresToUpload_ list, it removes the first element just before of trying to upload it. If it fails on the uploading, it adds again the dictionary with the information to the otherUserScoresToUpload_ list. The information it uploads is the the earnedScore_ to the user id. More... | |
void | writeFriendChallenges (string userId, string jsonLocal, string jsonCloud) |
This method compares the challenge list of the given user to upload correctly the information taking care of the differences between the local version and the cloud version. If something goes wrong it adds again the challenge property to the otherUsersPropertiesToUpload_ list. More... | |
void | writeFriendDeletedFriends (string userId, string jsonLocal, string jsonCloud) |
This method compares the deletedFriend list of the given user to upload correctly the information taking care of the differences between the local version and the cloud version. If something goes wrong it adds again the deletedFriend property to the otherUsersPropertiesToUpload_ list. More... | |
void | writeFriendAcceptedFriendsInvitations (string userId, string jsonLocal, string jsonCloud) |
This method compares the friendInvitations list of the given user to upload correctly the information taking care of the differences between the local version and the cloud version. If something goes wrong it adds again the friendInvitations property to the otherUsersPropertiesToUpload_ list. More... | |
Private Attributes | |
FirebaseApp | firebaseApp = null |
Reference to the FirebaseApp object. More... | |
GoogleSignInConfiguration | configuration |
bool | firebaseDependenciesResolved = false |
bool | firebaseDependenciesRunning = false |
bool | placesReady_ = false |
bool | userDataReady_ = false |
Dictionary< string, Dictionary< string, Dictionary< string, string > > > | allPlaces_ = new Dictionary<string,Dictionary<string,Dictionary<string,string>>>() |
List< Dictionary< string, string > > | placesToUpdateQueue_ |
List< string > | friendDataDownloadQueue_ |
List< string > | newFriendDataDownloadQueue_ |
bool | downloadingAnyOfTheUsersPermissionsLists_ |
true if it is trying to download any of the user permissions lists right now. false in other case. More... | |
bool | hasToUploadSocialPreferences_ |
true if there is changes on the social preferences that should be uploaded. More... | |
List< Dictionary< string, string > > | otherUserScoresToUpload_ |
List of dictionary strings with the user id and the score of that user that needs to be uploaded. More... | |
bool | uploadingNotifications_ |
Boolean that is used as a flag that indicates if the uploading of the acceptedFriendsInvitations property of a friend is uploading right now. More... | |
List< RankingPlayerData > | rankingData_ |
List with all the data that is showed on the ranking screen. It has a RankingPlayerData object for each player that appear on the ranking. More... | |
bool | allowDownloadRankingData_ |
Boolean that is used as a flag that indicates if its time to download all the ranking data. More... | |
bool | downloadingRankingData_ |
Boolean that is used as a flag that indicates if the ranking data is downloaded right now. More... | |
List< Dictionary< string, string > > | otherUsersPropertiesToUpload_ |
List< string > | currentUserPropertiesToUpload_ |
the part of the class firebaseHandler that controls the downloading operations
the part of the class firebaseHandler that controls the uploading operations
the part of the class firebaseHandler that controls the login user, create user, and logout operations
This class follows the Singleton patron, so it only has one instance at the same time. The instance could be found on the firebaseHandlerInstance_ public static property. This class handles all the firebase releated methods like validating user, creating new users, downloading and uploading all the data from the database. This class is a partial class it has another 3 files: downloadHandler.cs, uploadHandler.cs and loginHandler.cs.
void firebaseHandler.addOtherUserScoreToUpload | ( | Dictionary< string, string > | uidAndScore | ) |
This method adds the given dictionary to the otherUserScoresToUpload_ list.
Dictionary<string,string> | with the information of the score and the user id that need to be uploaded. |
void firebaseHandler.AnonymousUser | ( | ) |
This method tries to starts a session as an anonymous user, if it finish successfully it calls the downloading information methods and it also calls the anonymousUserLoginSucessfully method of the anonymousButtonHandler class.
Place firebaseHandler.askForAPlace | ( | ) |
This method calls askForAPlace method of requestHandler and returns the place that that method returns. If you want more information check the requestHandler documentation. This method also instanciate a requestHandler if it doesnt exists when its called.
void firebaseHandler.askForNewPlaces | ( | ) |
This method calls the updateStartIndex method of the requestHandler class to make the requestHandler choose new places.
|
private |
The awake method is called before the first frame, it checks if other firebaseHandler was instanciated before, if that is the case, it destroy this object.
|
private |
Task<DependencyStatus> | task to wait and take its results This method creates the firebase object and check if there is a previous session, it there is login that sesion. It also calls the method that download the places information and the user data. |
bool firebaseHandler.cooldownVisitingPlaceByNameFinished | ( | string | name | ) |
This method returns true if the place with the given name is ready for a new visit. The cooldown time is defined on the class gameRules, check that class for more information. You have to be aware that its possible that two places has the same name, on that case, it will check only the first one.
string | that contains the name of the place that you want to check if its ready to visit it again |
bool firebaseHandler.cooldownVisitingPlaceFinished | ( | string | type, |
int | id | ||
) |
This method returns true if the place with the given type and id is ready for a new visit. The cooldown time is defined on the class gameRules, check that class for more information.
string | with the type of the place we want to check |
int | with the id of the place we want to check |
bool firebaseHandler.cooldownVisitingStoredPlaceFinished | ( | StoredPlace | storedPlace | ) |
This method returns true if the place with the given type and id is ready for a new visit. The cooldown time is defined on the class gameRules, check that class for more information.
StoredPlace | the StoredPlace object that you want to check if you can visit it again. |
void firebaseHandler.CreateNewUser | ( | string | email, |
string | password | ||
) |
string | that contains the new user email. |
string | that contains the new user password. This method tries to create a new user on the firebase backend with the given email and password. |
|
private |
this method calls the downloadFriendData method with each user id that is on the friendDataDownloadQueue_.
|
private |
This method calls downloadNewFriendInvitationData method with each of the user ids that are on the new friends invitations list of the current user.
|
private |
This method start as many coroutines as types of places are defined on mapRulesHandler. Each coroutine will download the information of that type of place. If you want more information check the mapRulesHandler documentation and the downloadOneTypeOfSite method of this class.
void firebaseHandler.downloadFriendData | ( | string | uid | ) |
this method tries to download the necesary information of the given user id. If it fails on the process it adds the user id to the friendDataDownloadQueue_ list. If it success it calls the addFriendData method of UserData class creating a new FriendData object.
string | that contains the user id of the friend of the current user that you want to obtain data. |
|
private |
this method tries to download the display name and the list of newFriendsInvitations of the user that matches the given user id. If its fails it adds the user id to the newFriendDataDownloadQueue_ list and if its success, its calls the addNewFriendData method of UserData.
string | that contains the user id that you want to download the enough information for create the newFriendInvitation object. |
|
private |
This coroutine tries to download all the places of the given type. If there is no internet connection it waits until there is avaible again. When all the places of all types has already downloaded it sets ON the placesReady_ flag.
string | that contains the type of the sites you want to download the information. |
void firebaseHandler.downloadRankingPlayerData | ( | ) |
This method downloads all the data what will be shown on the players ranking and store it as a RankingPlayerData object on the rankingData_ list. It changes the downloadingRankingData_ attribute to reflect the current state of the download.
|
private |
This method download the lists of the user social permissions. They are usersThatAllowFriendshipInvitations, usersThatAllowBeChallenged and usersThatAllowAppearedOnRanking. The downloadingAnyOfTheUsersPermissionsLists_ is set as a true. The social permissions are downloaded in a parallel way for searching more efficiency if some of them failed the downloadingAnyOfTheUsersPermissionsLists_ property will be set as false again.
Dictionary< string, string > firebaseHandler.findPlaceByName | ( | string | name | ) |
this method returns a dictionary that contains the id and the type of the place that has the given name. If there isn't any place with that name, it will return a dictionary that contains two entries id with the string "-1" and type with the string "noType". If there is more than one place with the given name, only the first one will be returned.
string | that contains the name of the searched place |
bool firebaseHandler.FirebaseDependenciesAreResolved | ( | ) |
Getter of the flag that indicate that firebase dependencies are resolved or not.
Dictionary< string, string > firebaseHandler.getPlaceData | ( | string | type, |
string | id | ||
) |
This method search on the property allPlaces_ if there is a place with the given type and id. If there isn't any place that match both the given id and the given type, it will return null.
string | that contains the type of the searched place. |
string | that contains the id of the searched place. |
List< RankingPlayerData > firebaseHandler.getRankingPlayerData | ( | ) |
Getter of the rankingData_ propery.
RankingPlayerData firebaseHandler.getRankingPlayerDataById | ( | string | uid | ) |
This method returns the RankingPlayerData object with the data of the player who has the given user id. It would return null if there isnt any player with that id.
string | the user id of the user that you want to obtain the ranking data. |
bool firebaseHandler.hasUserVisitPlaceByName | ( | string | name | ) |
This method search on the places that the current user has visited and check if there is at least one place with that name, on that case it returns true, it returns false in other case.
string | that contains the name of the place that you want to check if current user has visit or not. |
bool firebaseHandler.internetConnection | ( | ) |
This method returns true only if there is internet connection, otherwise it will return false.
bool firebaseHandler.isDownloadingRankingDataNow | ( | ) |
getter of the downloadingRankingData_ property.
bool firebaseHandler.isRankingDataComplete | ( | ) |
This method returns true if all the data of the users that appeard on the ranking is already downloaded, false in other case.
void firebaseHandler.LoginUser | ( | string | email, |
string | password | ||
) |
string | that contains the user email that will try to login with. |
string | that contains the user password that will try to login with. This method tries to start a sesion with the given email and password, if it finish successfully it will call the downloading information methods and also call the emailLoginController userLogedSuccessfully method. |
void firebaseHandler.LogOut | ( | ) |
This method end the current firebase user sesion.
|
private |
This method is called when the application is closed, it saves all the offline information and stop the firebase online services.
|
private |
This method is called when the firebaseHandler object is destroyed.
|
private |
This method is called each time a scene is loaded, if placesReady_ variable is true, it calls the useStartIndex method of the requestHandler object, to allow keeping with same places.
Scene | the information of the scene it just has loaded. |
LoadSceneMode | object that contains the information of the way that the scene was loaded. |
bool firebaseHandler.placesAreReady | ( | ) |
void firebaseHandler.readUserData | ( | ) |
This method download all the information that is releated to the user from the firebase database.
void firebaseHandler.SearchOtherUserByName | ( | string | toSearch, |
string | type, | ||
SearchBar | toAdvise = null |
||
) |
This method tries to find other user on the list of users that allow be found by other users on the different types of searchs. If a SearchBar object is given it will call the resultsOfTheSearch method of that class with a dictionary version of the found user.
string | that contains the displayName that you want to search |
string | that contains the reason of the search, it could be friend, chanllege or ranking. This reasons for the search has to be differenciated because users can allow or not be found by other users. |
SearchBar | object that you want to advise when the search ends. This parameter is optional. |
void firebaseHandler.sendFriendshipInvitation | ( | string | uidToInvite, |
SearchedPlayer | searchedPlayerToAdvice | ||
) |
This method tries to send a new friendship invitation of the current user to the user that has the given id. The sending can produce three states:
string | that contains the user id of the player that the current user want to send a new friendship invitation. |
SearchedPlayer | object that handles the result of the sending
|
void firebaseHandler.SignInWithGoogle | ( | ) |
This method will be called when the google signin button is pressed, it start the google authentication process calling the method OnAuthenticationFinished when it finish.
void firebaseHandler.sortPlaces | ( | ) |
this method calls the sortPlaces method of the requestHandler class. Check that class documentation to get more information.
void firebaseHandler.sortRankingDataList | ( | ) |
This method sorts the users that appeard on the ranking. It sorts them setting on the firsts positions users with the highers scores. It also updates the top_ property of the RankingPlayerData objects of the lists using the setTop method.
int firebaseHandler.totalOfPlaces | ( | ) |
getter of the quantity of places
int firebaseHandler.totalOfPlacesOfZone | ( | string | zone | ) |
this method counts all the places that have the given zone name on their zone_ property. If there is no places on the given zone, it will show a message on the console and return a 0. The valid zones are determinated on the mapRulesHandler class, check its documentation for more information.
string | that contains the name of a zone. Valid zones are determinated on mapRulesHandler class. |
|
private |
The Update method is called every frame. On this method this class constantly check:
void firebaseHandler.updateUserAddedAFriend | ( | string | friendUid, |
string | acceptedFriendsInvitationsListInJSON | ||
) |
This method tries to upload the accepted friendships invitations list of the given user. If it complete it succesfully, it removes the friendUid of the list of the user that need to be notified with the hasBeenNotified method. It also sets the uploadingNotifications_ property as true but when the try of updating finish, in any way, it sets the uploadingNotifications_ property as false.
string | user id of the friend that has been acepted |
string | with the conversion of the accepted friendships invitations in JSON format. |
void firebaseHandler.updateUserDeleteAFriend | ( | string | noFriendUid, |
string | deletedFriendsListInJSON | ||
) |
This method must be called when there is internet connection, otherwise it wont to nothing. This method upload the deletedFriends property of the user that has the given id.
string | that contains the user that will has erased the friendship with the current user. |
string | that contains the deleted friends list of the user that has the given id in the JSON format. |
void firebaseHandler.uploadFriendChallengesOf | ( | FriendData | friendDataToUpload | ) |
this method upload the challengue list of the given user.
FriendData | object that contains all the information releated to the user that own the challenges we want to upload. |
|
private |
This method tries to upload the information of the first element of otherUserScoresToUpload_ list, it removes the first element just before of trying to upload it. If it fails on the uploading, it adds again the dictionary with the information to the otherUserScoresToUpload_ list. The information it uploads is the the earnedScore_ to the user id.
|
private |
this method tries to upload all the information that is on the placesToUpdateQueue_ property. If it success, it erase the place from the list, but if its fails the writePlaceData will add again the place to the queue.
void firebaseHandler.uploadSocialPreferences | ( | ) |
this method should be called either when there is changes on the current user's social preferences or the last changes couldnt been uploaded on the past. It checks if there is any change on the three permision and upload to the firebase database the changes on the preferences. It checks if the three lists are uploaded, if one or more of them fails on the uploading, it puts the hasToUploadSocialPreferences_ property to true, so this method will be called again when the internet connection is ready.
bool firebaseHandler.userDataIsReady | ( | ) |
void firebaseHandler.userVisitedPlace | ( | string | type, |
int | id, | ||
long | timeOfTheVisit = -1 |
||
) |
This method register a new visit for the place with the given type and id and the given timestamp, if the given timestamp is negative it will use the current timestamp. It also calls the writePlaceData and the writeUserData methods to upload the new visit information to the database.
string | that contains the type of the place that current user has visited and you want to register that visit. |
int | that contains the id of the place that current user has visited and you want to register that visit. |
long | that contains the timestamp of the visit, the default value is -1. A negative value means that you want to use the current timestamp not the given one. |
void firebaseHandler.userVisitedPlaceByName | ( | string | name, |
long | timeOfTheVisit = -1 |
||
) |
This method search on all the places the first one who match the given name, and then, it calls the userVisitedPlace method, check that method for more information. You have to be aware that if two places has the same name, the new visit will be added only to the first one.
string | that contains the name of the place that current user has visited and you want to register that visit. |
long | that contains the timestamp of the visit, the default value is -1. A negative value means that you want to use the current timestamp not the given one. |
void firebaseHandler.writeAllFriendProperties | ( | ) |
This method calls the writeFriendProperty with each element of the otherUsersPropertiesToUpload_ list and it removes the each of those elements taking care of that each of those elements could enter again on the list. That could happen if the upload goes wrong.
void firebaseHandler.writeAllUserProperties | ( | ) |
This method calls writeSafeProperties with each safe property and writeUnsafeProperty with each unsafe property of the current user. It uses the getJSONof method of UserData class.
|
private |
This method compares the friendInvitations list of the given user to upload correctly the information taking care of the differences between the local version and the cloud version. If something goes wrong it adds again the friendInvitations property to the otherUsersPropertiesToUpload_ list.
string | with the user id of the friend that will be uploaded |
string | with the json conversion of the friendInvitations list of that friend with the local information |
string | with the json conversion of the friendInvitations list of that friend with the cloud information |
|
private |
This method compares the challenge list of the given user to upload correctly the information taking care of the differences between the local version and the cloud version. If something goes wrong it adds again the challenge property to the otherUsersPropertiesToUpload_ list.
string | with the user id of the friend that will be uploaded |
string | with the json conversion of the challenges of that friend with the local information |
string | with the json conversion of the challenges of that friend with the cloud information |
|
private |
This method compares the deletedFriend list of the given user to upload correctly the information taking care of the differences between the local version and the cloud version. If something goes wrong it adds again the deletedFriend property to the otherUsersPropertiesToUpload_ list.
string | with the user id of the friend that will be uploaded |
string | with the json conversion of the deletedFriend list of that friend with the local information |
string | with the json conversion of the deletedFriend list of that friend with the cloud information |
void firebaseHandler.writeFriendProperty | ( | string | userId, |
string | property, | ||
string | json | ||
) |
This method downloads the current information of the given property of the given friend and then calls the correct method for taking care of differences between the cloud information and the local information.
string | with the user id of the friend that will be uploaded |
string | with the name of the property that needs to be uploaded |
string | with the json conversion of the property that needs to be uploaded |
void firebaseHandler.writeNewPlaceOnDataBase | ( | Place | place, |
string | type, | ||
int | placeID | ||
) |
void firebaseHandler.writePlaceData | ( | string | type, |
string | id | ||
) |
This method uploads the data from the place that matches the given type and id. If the upload fails it adds the information of the place to placesToUploadQueue_.
type | string that contains the type of the place that we want to upload. |
id | string that contains the id of the place that we want to upload. |
void firebaseHandler.writeQueuedUserProperties | ( | ) |
this method calls the writeSafeProperties or writeUnsafeProperty depending of the type of each element that is stored in currentUserPropertiesToUpload_ list. It removes the elements wich it calls those methods taking care of the fact that those properties could enter again on the currentUserPropertiesToUpload_ list if they fail on the upload.
void firebaseHandler.writeSafeProperties | ( | string | property, |
string | json | ||
) |
this method writes on the given property on the database the given json value. It doesnt take care of the version that is on the database. It simply overwrite it. If something goes wrong during the upload, it adds the property to currentUserPropertiesToUpload_ again.
string | that contains the name of the property |
string | that contains the json conversion of that property |
void firebaseHandler.writeUnsafeProperty | ( | string | property, |
string | json | ||
) |
this method writes on the given property on the database the given json value. It takes care of the information that is currently on the database and tries to avoid incongruencies of the database. If something goes wrong during the uploading it adds again the property to the currentUserPropertiesToUpload_ list.
string | that contains the name of the property |
string | that contains the json conversion of that property |
|
private |
Boolean that is used as a flag that indicates if its time to download all the ranking data.
|
private |
This atribute store all the data of the places downloaded from the database. The data stored as strings on a dictionary so they cant be directly used, its necessary to use the Place class for interpreting the information that is stored on this attribute. The data is structured as following:
|
private |
This object store the configuration for accessing the Google SingIn services, it stores for example the WebClientId token.
UserData firebaseHandler.currentUser_ = null |
A instance of the class UserData, it stores the downloaded data from the database, check the documentation of that class to get more information.
|
private |
|
private |
true if it is trying to download any of the user permissions lists right now. false in other case.
|
private |
Boolean that is used as a flag that indicates if the ranking data is downloaded right now.
|
private |
Reference to the FirebaseApp object.
|
private |
This flag is true when the firebase dependences are resolved and ready to use. If this flag is false, this class will try to resolve the firebase dependencies each frame.
|
private |
This flag is true when the firebase dependences are trying to be resolved right now. This flag prevent this class for making several calls to the firebase dependencies resolver method.
|
static |
This public static attribute store the unique instance of this class.
|
private |
It stores a list of the users ID that this class needs to download some information, because they are friends of the current user. As soon as the information is started to download, the uid is removed from the list.
|
private |
true if there is changes on the social preferences that should be uploaded.
|
private |
It stores a list of the users ID that this class needs to download some information because they sended a new friend invitation. As soon as the information is started to download, the uid is removed from the list.
|
private |
List of dictionary strings with the user id and the score of that user that needs to be uploaded.
|
private |
|
private |
This flag determinate if the information of the interesting points are already downloaded from the database and its ready to use.
|
private |
This atribute stores the list of places that have been visited but the internet conection have failed when this class tried to upload it. This class will try to upload that information since it gets internet connection again.
|
private |
List with all the data that is showed on the ranking screen. It has a RankingPlayerData object for each player that appear on the ranking.
requestHandler firebaseHandler.requestHandler_ |
This atribute stores an instance of the requestHandler class, that class converts the information of allPlaces_ on instances of the class Place. Check that class documentation for more info.
|
private |
Boolean that is used as a flag that indicates if the uploading of the acceptedFriendsInvitations property of a friend is uploading right now.
|
private |
If this flag is true, the information of the user are already downloaded from the databse and its ready to use.