static void Main(string[] args) { ViewConfiguration vc = new ViewConfiguration(); vc.Caching = true; //vc.PluginFolder = ""; vc.WwwrootFolder = AppContext.BaseDirectory; vc.ViewFolder = System.IO.Path.Combine(AppContext.BaseDirectory, "../../../Views/"); vc.HomePath = "/"; vc.ViewExtension = ".tpl"; vc.Caching = false; //plugin register vc.PluginAssemblies.Add(typeof(Program).Assembly); // ViewEngine = new ViewEngine(vc); Adf.HttpServer server = new Adf.HttpServer(8080); server.Callback = HttpServerCallback; server.Start(); Console.WriteLine("ok"); Console.ReadLine(); }
public HttpServerTest() { var server = new Adf.HttpServer(8080); server.Callback = this.HttpServerCallback; server.AuthorizationCallback = this.HttpServerAuthorizationCallback; server.Start(); Console.WriteLine("Port:{0}", server.Port); Console.ReadLine(); }
public static void Test() { var server = new Adf.HttpServer(WebCallback, 888); //设置新连接回调 server.WebSocketConnectioned += Connection; server.WebSocketDisconnected += Disconnect; server.WebSocketNewMessage += Message; server.Start(); using (var client = new Adf.WebSocketClient("127.0.0.1", 888)) { client.Message += (object sender, WebSocketMessageEventArgs e) => { if (e.Opcode == WebSocketOpcode.Text) { Console.WriteLine("C Receive: {0}", e.Message); } else { Console.WriteLine("C Receive Opcode:{0}", e.Opcode); } }; client.Connection(); while (client.IsConnectioned) { var msg = "m" + DateTime.Now.Ticks.ToString(); Console.WriteLine(); Console.WriteLine("C Say " + msg); client.Send(msg); Thread.Sleep(1000); } Console.WriteLine("Close"); } Console.ReadLine(); server.Stop(); }
public static void Test() { datas[0] = new byte[511]; datas[1] = new byte[1024]; datas[2] = new byte[4097]; datas[3] = new byte[9555]; // var server = new Adf.HttpServer(WebCallback, 888); //设置新连接回调 server.WebSocketConnectioned += Connection; server.WebSocketDisconnected += Disconnect; server.WebSocketNewMessage += Message; server.Start(); Console.ReadLine(); server.Stop(); }
public HttpServerTest2() { var server = new Adf.HttpServer(8080); server.Callback = this.HttpServerCallback; server.Start(); Console.WriteLine("Port:{0}", server.Port); WebClient wc; string content; wc = new WebClient(); content = wc.DownloadString("http://127.0.0.1:8080/"); Console.WriteLine("Server Time:" + content); wc = new WebClient(); content = wc.DownloadString("http://127.0.0.1:8080/"); Console.WriteLine("Server Time:" + content); wc = new WebClient(); content = wc.UploadString("http://127.0.0.1:8080/?a=b", "POST", "value=x"); Console.WriteLine("Server Time:" + content); wc = new WebClient(); content = wc.UploadString("http://127.0.0.1:8080/?a=b", "POST", "value=x"); Console.WriteLine("Server Time:" + content); //wc = new WebClient(); //content = server.Encoding.GetString(wc.UploadFile("http://127.0.0.1:8080/", "POST", "c:\\windows\\explorer.exe")); //Console.WriteLine("File:" + content); //wc = new WebClient(); //content = server.Encoding.GetString(wc.UploadFile("http://127.0.0.1:8080/", "POST", "c:\\windows\\explorer.exe")); //Console.WriteLine("File:" + content); Console.ReadLine(); }