示例#1
0
        public void Send()
        {
            _timestart  = IDate.Now.getTime();
            TimeElapsed = 0;

            LastException = null;

            if (BeforeSend != null)
            {
                BeforeSend(this);
            }

            if (Descriptor.Description == null)
            {
                string err = "header not set";

                Console.LogError(err);

                if (DemandHeader)
                {
                    throw new ScriptException(err);
                }
            }


            string json = ToJSON();

            if (IsVerbose)
            {
                Console.Log(" => [" + Descriptor.Description + "] " + json.Length + " bytes");
            }

            Worker.StartInterval();



            if (IsVerbose)
            {
                Console.WriteLine("var data = " + json + ";");
                Console.Log(json.Length + " bytes sent");
            }

            if (Form == null)
            {
                Request.open(HTTPMethodEnum.POST, Url);
                Request.send(json);
                Request.InvokeOnComplete(
                    delegate
                {
                    ResponseText = Request.responseText;

                    GotResponse();
                });
            }
            else
            {
                IHTMLInput z = new IHTMLInput(HTMLInputTypeEnum.hidden);

                z.name  = Helper.FormTemplateJSONField;
                z.value = Convert.ToBase64String(json);

                Form.appendChild(z);
                Form.target = Descriptor.Callback;
                Form.submit();

                z.Dispose();
            }
        }