Exemplo n.º 1
0
    void PerformQueryByServerCode()
    {
        message       = "QueryByServerCode...";
        ButtonEnabled = false;

        JsonObject rawArgs = new JsonObject();

        rawArgs.Put("baseUrl", Kii.BaseUrl);
        rawArgs.Put("groupUri", group.Uri.ToString());
        rawArgs.Put("bucketName", bucketName);
        KiiServerCodeEntryArgument args = KiiServerCodeEntryArgument.NewArgument(rawArgs);

        KiiServerCodeEntry entry = Kii.ServerCodeEntry("sum");

        entry.Execute(args, (KiiServerCodeEntry en, KiiServerCodeEntryArgument argument, KiiServerCodeExecResult execResult, Exception e) =>
        {
            buttonEnable = true;
            if (e != null)
            {
                message = "Failed to execute server code " + e.ToString();
                return;
            }
            JsonObject resultJson = execResult.ReturnedValue;
            message = resultJson.GetString("returnedValue");
        });
    }
Exemplo n.º 2
0
 void OnGUI()
 {
     this.entryNameValue = gui.TextField(
         10,
         10,
         300,
         50,
         this.entryNameValue);
     this.versionValue = gui.TextField(
         10,
         70,
         300,
         50,
         this.versionValue);
     if (gui.Button(
             10,
             130,
             300,
             60,
             "ServerCodeEntry(entryName)"))
     {
         try {
             execEntry(Kii.ServerCodeEntry(this.entryNameValue));
         } catch (Exception e) {
             this.labelText = e.ToString();
         }
     }
     if (gui.Button(
             10,
             200,
             300,
             60,
             "ServerCodeEntry(entryName, version)"))
     {
         try {
             execEntry(Kii.ServerCodeEntry(this.entryNameValue,
                                           this.versionValue));
         } catch (Exception e) {
             this.labelText = e.ToString();
         }
     }
     if (gui.Button(
             10,
             270,
             145,
             60,
             "User login"))
     {
         this.labelText = "";
         string  username = "******" + DateTime.Now.Ticks.ToString();
         KiiUser user     = KiiUser.BuilderWithName(username).Build();
         user.Register("pa$$sword", (KiiUser u, Exception e1) => {
             if (e1 == null)
             {
                 this.labelText = "SUCCESS:\nuser="******"User logout"))
     {
         KiiUser.LogOut();
         this.labelText = "User logged out";
     }
     gui.TextField(
         10,
         350,
         300,
         120,
         this.labelText);
 }