static void Main(string[] args) { __CHAT_ORGIN = new List <string> { "tripecosys.pc" }; SetConsoleCtrlHandler(new HandlerRoutine(ConsoleCtrlCheck), true); Console.WriteLine("CTRL+C,CTRL+BREAK or suppress the application to exit"); CancellationToken _ct = _cancellationTokenSource.Token; using (var tx = new HttpServer(5, _ct)) { using (var wsh = new WebSocketHandler()) { tx.ProcessRequest += delegate(System.Net.HttpListenerContext context, CancellationToken ct) { if (!context.Request.IsWebSocketRequest) { context.Response.ContentType = "text/html"; string responseString = "<strong style='color:red; font-size:16px;'>Invalid Request defined. :(</strong>"; byte[] buffer = System.Text.Encoding.UTF8.GetBytes(responseString); // Get a response stream and write the response to it. context.Response.ContentLength64 = buffer.Length; context.Response.OutputStream.Write(buffer, 0, buffer.Length); context.Response.Close(); return; } //{name:"", email:"", piority:"", token:"", is_client:"", connection_token:""}; var info = context.Request.QueryString["info"]; if (info == null) { context.Response.StatusCode = 505; context.Response.StatusDescription = "User information should be provied!!!"; context.Response.Abort(); return; } wsh.AcceptWebSocketAsync(info, true, context, _ct); }; tx.Start("http://127.0.0.1/socket/"); while (!_ct.IsCancellationRequested) { ; } System.Threading.Thread.Sleep(1000); } tx.Stop(); } //Console.WriteLine(string.Join(", ", getArray(new int[] { 1, 2, 3, 4, 5 }))); return; }