Exemple #1
0
 public void AddUser(string id)
 {
     if (users.Find(x => x.name == id) == null)
     {
         var user = new CloudAPI.AdminData()
         {
             name = id
         };
         users.Add(user);
         StartCoroutine(cloud.PostAdmin(user,
                                        (long responseCode) =>
         {
             Debug.Log("Admin added!");
         }, (CloudAPI.ErrorDetails error) =>
         {
             Debug.LogError(error);
         }));
     }
     else
     {
         Debug.Log("already registred");
     }
     DestroyItems();
     RenderList();
 }
Exemple #2
0
 public IEnumerator DeleteAdmin(AdminData admin,
                                Action <long> onSuccess, Action <ErrorDetails> onError)
 {
     return(WebRequest(
                RequestType.kDELETE,
                $"{baseURI}/admins",
                ConvertOnSuccess(onSuccess),
                onError,
                JSONRequestBody.FromObject(admin)));
 }
Exemple #3
0
        public IEnumerator PostAdmin(AdminData admin, Action <long> onSuccess, Action <ErrorDetails> onError)
        {
            yield return(new WaitForSeconds(waitDelay));

            if (forcedError != null)
            {
                onError(forcedError);
                yield break;
            }

            admins.Add(admin);
            onSuccess(200);
        }
Exemple #4
0
        public IEnumerator DeleteAdmin(AdminData admin, Action <long> onSuccess, Action <ErrorDetails> onError)
        {
            yield return(new WaitForSeconds(waitDelay));

            if (forcedError != null)
            {
                onError(forcedError);
                yield break;
            }

            int count = admins.RemoveAll((AdminData a) => { return(a.name == admin.name); });

            if (count != 0)
            {
                onSuccess(200);
            }
            else
            {
                onError(GenProtocolErrorDetails(400));
            }
        }