public int InvokePlugin(FlamingLeaf.Api.FlamingApiRequest apiRequest, FlamingLeafToolkit.FlamingApiClientInformation clientInformation)
        {
            string apiRequest__json = (string)InvokeHostMethod("ObjectToJson", apiRequest);
            Console.WriteLine("[SIMPLEDB] API REQUEST: <{0}, secret: {1}> {2}", clientInformation.IPAddress, clientInformation.Secret, apiRequest__json);

            char dirSep = System.IO.Path.DirectorySeparatorChar;
            int ret = 0;
            //Plugin Invocation Callback
            string action = apiRequest.Action;
            //Jail the path to the client's own Secret
            SimpleDB.SetJailRootSub(dirSep + clientInformation.Secret);
            string path = clientInformation.Secret + dirSep + apiRequest.Arguments[0];

            //Standard commands
            if (action == "CREATE_PROFILE")
            {
                int aret = SimpleDB.CreateProfile(path);
                int status = aret == 0 ? 200 : 11; //OK
                var apiResp = new FlamingLeaf.Api.FlamingApiRequest()
                {
                    Action = "Acknowledge",
                    Status = status,
                };
                SendResponseToClient(apiResp);
            }
            if (action == "WRITE_PROFILE_DATA")
            {
                string fileName = apiRequest.Arguments[1];
                string contents = apiRequest.Arguments[2];
                int aret = SimpleDB.WriteProfileData(path, fileName, contents);
                int status = aret == 0 ? 200 : 11; //OK
                var apiResp = new FlamingLeaf.Api.FlamingApiRequest()
                {
                    Action = "Acknowledge",
                    Status = status,
                };
                SendResponseToClient(apiResp);
            }
            if (action == "READ_PROFILE_DATA")
            {
                string fileName = apiRequest.Arguments[1];
                string contents;
                int aret = SimpleDB.ReadProfileData(path, fileName, out contents);
                int status = aret == 0 ? 200 : 11; //OK
                string message = contents;
                if (message == null)
                {
                    message = "Error";
                    status = 11; //Error
                }
                var apiResp = new FlamingLeaf.Api.FlamingApiRequest()
                {
                    Action = "ReadResponse",
                    Arguments = new string[] { message },
                    Status = status,
                };
                SendResponseToClient(apiResp);
            }

            //Low-level commands
            if (action == "CREATE_DIR")
            {
                SimpleDB.CreateDirectory(path);
            }
            if (action == "WRITE_FILE")
            {
                string contents = apiRequest.Arguments[1];
                SimpleDB.WriteFile(path, contents);
            }
            return ret;
        }
 public void SendResponseToClient(FlamingLeaf.Api.FlamingApiRequest apiResponse)
 {
     string j64 = (string)InvokeHostMethod("CraftApiRequest", apiResponse);
     InvokeHostMethod("SetLastResponse", j64); //Set response
     InvokeHostMethod("SendLastMessageToLastClient"); //Send Response
 }