当前位置: 首页>>代码示例>>C#>>正文


C# HttpProcessor.writeSuccess方法代码示例

本文整理汇总了C#中Bend.Util.HttpProcessor.writeSuccess方法的典型用法代码示例。如果您正苦于以下问题:C# HttpProcessor.writeSuccess方法的具体用法?C# HttpProcessor.writeSuccess怎么用?C# HttpProcessor.writeSuccess使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bend.Util.HttpProcessor的用法示例。


在下文中一共展示了HttpProcessor.writeSuccess方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Deal

		private void Deal(HttpProcessor p,string url, string data,bool isGet){
			if(url==null){
				return;
			}
			if(url=="/"||url.StartsWith("/room.php")||url.StartsWith("/room.json")){
				//房间列表
				p.writeSuccess();
				p.outputStream.Write(GetContent(url, data));
			}else if(url.StartsWith("/deck.php")){
				//卡片列表
				if(data.IndexOf("pwd=caicai")<0){
					p.writeFailure();
					return;
				}
				p.writeSuccess();
				string[] args = data.Split('&');
				foreach(string a in args){
					if(a != null && a.StartsWith("name=")){
						int i = a.IndexOf("=");
						if(i>=0 && i< a.Length-1){
							string name = a.Substring(i+1);
							List<int> cards = GameManager.GameCards(name);
							foreach(int id in cards){
								p.outputStream.WriteLine(""+id);
							}
						}
					}
				}
			}
			else{
				p.writeFailure();
			}
		}
开发者ID:247321453,项目名称:YgoServer,代码行数:33,代码来源:MyHttpServer.cs

示例2: handleGETRequest

        public override void handleGETRequest(HttpProcessor p)
        {
            string urlText = p.http_url;

            int pos = urlText.IndexOf("&");
            if (pos != -1)
            {
                urlText = urlText.Substring(0, pos);
            }

            if (urlText.EndsWith("/getSnapshot") == true)
            {
                p.writeSuccess("application/json");
                p.outputStream.Write(_document.SnapshotText);
            }
            else if (urlText.Contains("/setSlide/") == true)
            {
                string txt = urlText.Substring(urlText.LastIndexOf('/') + 1);

                int slide;
                if (Int32.TryParse(txt, out slide) == true)
                {
                    _document.SetCurrentSlide(slide);
                }

                p.writeSuccess("text/html");
                p.outputStream.Write("OK");
            }
            else if (urlText.Contains("/startShow/") == true)
            {
                string txt = urlText.Substring(urlText.LastIndexOf('/') + 1);

                int slide;
                if (Int32.TryParse(txt, out slide) == true)
                {
                    _document.StartShow(slide);
                }

                p.writeSuccess("text/html");
                p.outputStream.Write("OK");
            }
            else if (urlText.Contains("/startShow") == true)
            {
                _document.StartShow(1);
                p.writeSuccess("text/html");
                p.outputStream.Write("OK");
            }
            else if (urlText.Contains("/nextAnimation") == true)
            {
                _document.NextAnimation();
                p.writeSuccess("text/html");
                p.outputStream.Write("OK");
            }
        }
开发者ID:stjeong,项目名称:OfficePresenter,代码行数:54,代码来源:MyHttpServer.cs

示例3: handleGETRequest

        public override void handleGETRequest(HttpProcessor p)
        {
            Console.WriteLine("request: {0}", p.http_url);
            p.writeSuccess();

            //p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            //p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
            //p.outputStream.WriteLine("url : {0}", p.http_url);

            //p.outputStream.WriteLine("<form method=post action=/form>");
            //p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
            //p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
            //p.outputStream.WriteLine("</form>");

            if (p.http_url.Contains("www"))
            {
                string appPath = Path.GetDirectoryName(Application.ExecutablePath);
                string fileName = appPath + "/" + p.http_url.Substring(p.http_url.IndexOf("www"));
                FileInfo fi = new FileInfo(fileName);
                using (StreamReader sr = new StreamReader(fi.OpenRead()))
                {
                    p.outputStream.Write(sr.ReadToEnd());
                }
            }
            else
            {
                System.Web.Script.Serialization.JavaScriptSerializer j = new System.Web.Script.Serialization.JavaScriptSerializer();

                p.outputStream.WriteLine(j.Serialize(Temps));
            }
        }
开发者ID:skthumperd,项目名称:SharpTemp,代码行数:31,代码来源:MyHttpServer.cs

示例4: handleGETRequest

        public override void handleGETRequest(HttpProcessor processor)
        {
            Console.WriteLine("--GET REQUEST BEGIN--");
            Console.WriteLine("Request:\n\t" + processor.http_url);
            Console.WriteLine("Parameter:");

            Console.WriteLine("\nSearching Handler..");
            foreach (ITaskReciverPlugin cmd in pluginLoader.LoadedPlugins)
            {
                if (processor.http_url.StartsWith(cmd.CommandTrigger))
                {
                    Console.Write(" Found!");

                    List<Tuple<string, string>> param = new List<Tuple<string,string>>();

                    param = GetParams(processor.http_url, cmd.CommandTrigger);

                    param.ForEach(x => Console.WriteLine("\t" + x.Item1 + " = " + ((x.Item2 == "") ? "no value" : x.Item2)));

                    Console.WriteLine("Executing!");
                    Console.WriteLine("--GET REQUEST END--\n");

                    cmd.Execute(param);
                    processor.writeSuccess();
                    return;
                }
            }

            processor.writeFailure();
            Console.Write(" Non Found :(");
            Console.WriteLine("--GET REQUEST END--\n");
        }
开发者ID:Kimmax,项目名称:TaskReceiver,代码行数:32,代码来源:Server.cs

示例5: handlePOSTRequest

        public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
        {
            MoaLog.Debug(String.Format("POST request: {0}", p.http_url));
            string data = inputData.ReadToEnd();

            p.writeSuccess();
            p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            p.outputStream.WriteLine("<a href=/test>return</a><p>");
            p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
        }
开发者ID:honomoa,项目名称:SimpleHttpServer,代码行数:10,代码来源:SimpleHttpServer.cs

示例6: handleGETRequest

        public override void handleGETRequest(HttpProcessor p)
        {
            if (p.http_url.Equals("/Test.png"))
            {
                Stream fs = File.Open("../../Test.png", FileMode.Open);

                p.writeSuccess("image/png");
                fs.CopyTo(p.outputStream.BaseStream);
                p.outputStream.BaseStream.Flush();
            }

            MoaLog.Debug(String.Format("request: {0}", p.http_url));
            p.writeSuccess();
            p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
            p.outputStream.WriteLine("url : {0}", p.http_url);

            p.outputStream.WriteLine("<form method=post action=/form>");
            p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
            p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
            p.outputStream.WriteLine("</form>");
        }
开发者ID:honomoa,项目名称:SimpleHttpServer,代码行数:22,代码来源:SimpleHttpServer.cs

示例7: handlePOSTRequest

        public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
        {
            Console.WriteLine("POST request: {0}", p.http_url);
            var stopWatch = new Stopwatch();
            stopWatch.Start();

            string data = inputData.ReadToEnd();
            var board = JsonConvert.DeserializeObject<DynaShipBoard>(data);
            var response = new DynaShipAI(board).Process();
            p.writeSuccess("application/json");
            p.outputStream.Write(String.Format("{{\"x\": {0}, \"y\": {1}}}", response.X, response.Y));

            stopWatch.Stop();
            Console.WriteLine("Time taken: " + stopWatch.Elapsed);
        }
开发者ID:nilsgudmundsson,项目名称:DynaShipClientCSharp,代码行数:15,代码来源:DynaShipServer.cs

示例8: handleGETRequest

        public override void handleGETRequest(HttpProcessor p)
        {
            Console.WriteLine("request: {0}", p.http_url);
            p.writeSuccess();

            string callback = String.Empty;
            this.setData(ParseParameters(p.http_url, out callback));

            try
            {
                p.outputStream.WriteLine(callback + "(\"OK\")");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: {0}", ex.Message);
            }
        }
开发者ID:n0nick,项目名称:pewpew,代码行数:17,代码来源:KinectHttpServer.cs

示例9: handleGETRequest

 public override void handleGETRequest(HttpProcessor p)
 {
     Console.WriteLine ("request: {0}", p.http_url);
     if (p.http_url.Equals ("/")) {
         // return form
         WriteForm (p);
     } else {
         //return static file
         try {
             FileInfo f = new FileInfo(p.http_url.TrimStart('/'));
             if (f.Exists) {
                 StreamReader s = new StreamReader(f.FullName);
                 p.writeSuccess();
                 p.outputStream.Write(s.ReadToEnd());
             } else {
                 p.writeFailure();
             }
         } catch(Exception e) {
             p.writeFailure();
         }
     }
 }
开发者ID:bi-tm,项目名称:openABAP,代码行数:22,代码来源:Server.cs

示例10: handlePOSTRequest

        public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData)
        {
            Console.WriteLine("POST request: {0}", p.http_url);
            string data = inputData.ReadToEnd();

            p.writeSuccess();

            String[] args = data.Split('&');
            Dictionary<String, String> act_args = new Dictionary<string, string>();
            foreach (String s in args)
            {
                String[] arg_pair = s.Split('=');
                act_args[arg_pair[0]] = arg_pair[1];
            }

            bool success = false;

            if (p.http_url.Equals("/vote/index.csh"))
            {
                String user = act_args["user"];
                String pass = act_args["pw"];
                String md5pass = Util.getMD5Hash(pass);
                int uid = Convert.ToInt32(act_args["uid"]);

                success = pl.vote(uid, um.getUser(user, md5pass));

                p.outputStream.WriteLine("<h1>Vote aftersite</h1>");
                p.outputStream.WriteLine("<a href=/vote/vote.csh>Vote was {0}</a><p>", (success) ? "successfull" : "not successfull");
            }
            else if (p.http_url.Equals("/vote/pass.csh"))
            {
                Dictionary<String, String> vars_to_pass = new Dictionary<string,string>();
                vars_to_pass["UID"] = act_args["uid"];

                openFile("/vote/pass.csh", p.outputStream, vars_to_pass);
            }

            //p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
        }
开发者ID:needspeed,项目名称:VotemUp,代码行数:39,代码来源:MyHttpServer.cs

示例11: handlePOSTRequest

        public override void handlePOSTRequest(HttpProcessor p, StreamReader inputData) {
            Console.WriteLine("POST request: {0}", p.http_url);
            string data = inputData.ReadToEnd();
            StreamWriter sw = new StreamWriter("datei.json");
            sw.Write(data);
            sw.Close();
            Console.WriteLine(data);
            p.writeSuccess();
            p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            p.outputStream.WriteLine("<a href=/test>return</a><p>");
            p.outputStream.WriteLine("postbody: <pre>{0}</pre>", data);
            

        }
开发者ID:Basti110,项目名称:HttpCardDAV,代码行数:14,代码来源:SimpleHttpServer.cs

示例12: handleGETRequest

        public override void handleGETRequest(HttpProcessor p)
        {
            Console.WriteLine("request: {0}", p.http_url);
            p.writeSuccess();
            /*p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            p.outputStream.WriteLine("Current Time: 오전" + DateTime.Now.ToString());
            p.outputStream.WriteLine("url : {0}", p.http_url);

            p.outputStream.WriteLine("<form method=post action=/form>");
            p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
            p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
            p.outputStream.WriteLine("</form>");*/
            p.outputStream.WriteLine("<data>");
            p.outputStream.WriteLine("<array1>2");
            p.outputStream.WriteLine("</array1>");
            p.outputStream.WriteLine("</data>");
        }
开发者ID:jaedong27,项目名称:smartcube,代码行数:17,代码来源:SimpleHttpServer.cs

示例13: handleGETRequest

        public override void handleGETRequest(HttpProcessor p)
        {
            if (p.http_url.Equals ("/Test.png")) {
                Stream fs = File.Open("../../Test.png",FileMode.Open);

                p.writeSuccess("image/png",fs.Length);
                p.outputStream.Flush();
                fs.CopyTo (p.outputStream.BaseStream);
                p.outputStream.BaseStream.Flush ();
                fs.Close();
                return;
            }

            if (p.http_url.StartsWith ("/m3u8")) {
                string path = "http://scgd-m3u8.joyseetv.com:10009";
                path += p.http_url;
                path += GenKey();

                if (p.http_url == pid && DateTime.Now.Subtract(lastQueryTime).TotalSeconds < 10)
                    {
                        p.writeSuccess("application/vnd.apple.mpegurl", length);
                        p.outputStream.Flush();
                        Stream fs2= new MemoryStream(copyfsbytes, 0, (int)length);
                        fs2.CopyTo(p.outputStream.BaseStream);
                        p.outputStream.BaseStream.Flush();
                    fs2.Close();

                    Console.WriteLine("1:"+lastQueryTime + DateTime.Now);
                    return;
                }
                else
                {
                    copyfsbytes = new byte[5000];

                }

                    pid = p.http_url;
                    lastQueryTime = DateTime.Now;
                    Console.WriteLine("2:" + lastQueryTime + DateTime.Now);

                // The downloaded resource ends up in the variable named content.

                // Initialize an HttpWebRequest for the current URL.
                var webReq = (HttpWebRequest)WebRequest.Create(path);

                webReq.UserAgent = "Android/TVPlayerSDK/1.0";
                WebResponse response = webReq.GetResponse();
                Stream fs = webReq.GetResponse().GetResponseStream();
                fs.Read(copyfsbytes, 0, (int)response.ContentLength);
                fs = new MemoryStream(copyfsbytes,0, (int)response.ContentLength);
                length = response.ContentLength;

                p.writeSuccess("application/vnd.apple.mpegurl", response.ContentLength);
                p.outputStream.Flush();
                fs.CopyTo (p.outputStream.BaseStream);
                p.outputStream.BaseStream.Flush ();
                fs.Close();
                return;
            }

            Console.WriteLine("request: {0}", p.http_url);
            p.writeSuccess();
            p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
            p.outputStream.WriteLine("url : {0}", p.http_url);

            p.outputStream.WriteLine("<form method=post action=/form>");
            p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
            p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
            p.outputStream.WriteLine("</form>");
        }
开发者ID:masonwu21,项目名称:fileserver,代码行数:71,代码来源:SimpleHttpServer.cs

示例14: LandingPage

        private void LandingPage(HttpProcessor p)
        {
            p.writeSuccess();
            Stream fs = File.Open("../../../html/index.html", FileMode.Open);
            StreamReader reader = new StreamReader(fs);
            string html = reader.ReadToEnd();
            fs.Close();

            html = html.Replace("#UTTERANCE#", lastrequest);

            string addString;
            addString = "";
            foreach (string s in Targets) addString += htmlListElement(s);
            html = html.Replace("#TARGETS#", addString);

            addString = "";
            foreach (string s in Instructions) addString += htmlListElement(s);
            html = html.Replace("#INSTRUCTIONS#", addString);

            
    
            /*p.outputStream.WriteLine("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>");
            p.outputStream.WriteLine("<html xmlns=/'http://www.w3.org/1999/xhtml'>");
            p.outputStream.WriteLine("<head><meta http-equiv='Content-Type' content='text/html; charset=UTF-8' /><title>EMOTE Utterance Tester</title></head><body>");
            p.outputStream.WriteLine("<form name='input' action='performUtterance' method='post'><textarea type='text' name='utterance' rows='10' cols='150'>" + lastrequest + "</textarea><br><input type='submit' value='Perform'></form><br>");

            p.outputStream.WriteLine("Available Targets:<br>");
            foreach (string s in Targets) p.outputStream.WriteLine(s + "<br>");

            p.outputStream.WriteLine("</body></html>");*/
            p.outputStream.WriteLine(html);
            p.outputStream.BaseStream.Flush();   
        }
开发者ID:emote-project,项目名称:Scenario1,代码行数:33,代码来源:SimpleHttpServer.cs

示例15: handleGETRequest

        public override void handleGETRequest(HttpProcessor p)
        {


            string wantedUrl = p.http_url;


            string[] splittenUrl = wantedUrl.Split('/');
            string action = splittenUrl[1];

            if (String.Equals(action, "space",
                   StringComparison.OrdinalIgnoreCase))
            {
                p.writeSuccess();
                p.outputStream.WriteLine("SPACE");
                SendKeys.SendWait(" ");

            }
            else if (String.Equals(action, "back",
                   StringComparison.OrdinalIgnoreCase))
            {
                p.writeSuccess();
                p.outputStream.WriteLine("back");
                SendKeys.SendWait("{LEFT} {LEFT} {LEFT} {LEFT} {LEFT}");

            }
            else if (String.Equals(action, "forward",
                   StringComparison.OrdinalIgnoreCase))
            {
                p.writeSuccess();
                p.outputStream.WriteLine("forward");
                SendKeys.SendWait("{RIGHT} {RIGHT} {RIGHT} {RIGHT} {RIGHT}");

            }
            
            
            /*
            Console.WriteLine("request: {0}", p.http_url);
            p.writeSuccess();
            p.outputStream.WriteLine("<html><body><h1>test server</h1>");
            p.outputStream.WriteLine("Current Time: " + DateTime.Now.ToString());
            p.outputStream.WriteLine("url : {0}", p.http_url);

            p.outputStream.WriteLine("<form method=post action=/form>");
            p.outputStream.WriteLine("<input type=text name=foo value=foovalue>");
            p.outputStream.WriteLine("<input type=submit name=bar value=barvalue>");
            p.outputStream.WriteLine("</form>");*/
        }
开发者ID:coolcheat,项目名称:SimpleAutomationWebServer,代码行数:48,代码来源:SimpleHttpServer.cs


注:本文中的Bend.Util.HttpProcessor.writeSuccess方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。