Exemplo n.º 1
0
 public void ActiveUserMessagesListener(string userID, string userType, Delegates.GetUserMessages success)
 {
     userMessages += success;
     if (userType == Constants.UserType.Responsible.ToString())
     {
         FirebaseDatabase.DefaultInstance.GetReference(DBTable.Responsible.ToString()).Child(userID).Child(Parameters.messages.ToString())
         .ValueChanged += MessagesListChanged;
     }
     else if (userType == Constants.UserType.Company.ToString())
     {
         FirebaseDatabase.DefaultInstance.GetReference(DBTable.Company.ToString()).Child(userID).Child(Parameters.messages.ToString())
         .ValueChanged += MessagesListChanged;
     }
     else
     {
         FirebaseDatabase.DefaultInstance.GetReference(DBTable.User.ToString()).Child(userID).Child(Parameters.messages.ToString())
         .ValueChanged += MessagesListChanged;
     }
 }
Exemplo n.º 2
0
 public void GetUserMessages(string userID, Delegates.GetUserMessages success, Delegates.GeneralListenerFail fail)
 {
     FirebaseDatabase.DefaultInstance.GetReference(DBTable.User.ToString()).Child(userID).Child(Parameters.messages.ToString())
     .GetValueAsync().ContinueWith(task => {
         if (task.IsFaulted)
         {
             fail(task.Exception.ToString());
         }
         else if (task.IsCompleted)
         {
             DataSnapshot snapshot        = task.Result;
             List <MessageModel> messages = new List <MessageModel> ();
             foreach (var message in snapshot.Children)
             {
                 string json           = message.GetRawJsonValue();
                 MessageModel mMessage = JsonUtility.FromJson <MessageModel> (json);
                 messages.Add(mMessage);
             }
             success(messages);
         }
     });
 }