public void SetUp() { mockSocket = null; verb = requestUri = httpVersion = body = null; headers = null; context = null; contextGeneratedUnit = false; contextException = null; }
IEnumerable<IYieldable> AcceptConnections() { while (!stopping) { var accept = listener.AcceptAsync(); yield return accept; var start = DateTime.Now; if (accept.Exception != null) { //Console.WriteLine("Exception while accepting connection!"); Console.Out.WriteException(accept.Exception); continue; } lock (this) numConnections++; //Console.WriteLine("Accepted a connection."); Socket socket = accept.Result; // socket is closed by context if no exception occurs if (socket == null) yield break; var context = new KayakContext(this, socket); // TODO : Ferhat buraya loglama isini pasliyorum context.CanLog = false; Scheduler.Default.Add(new ScheduledTask() { Coroutine = context.HandleConnection().Coroutine(), Callback = coroutine => { if (coroutine.Exception != null) { //Console.WriteLine("Exception during HandleConnection"); Console.Out.WriteException(coroutine.Exception); } //Console.Write("closing socket..."); socket.Close(); socket = null; if (CanLog) Console.WriteLine("{0}ms", (DateTime.Now - start).TotalMilliseconds); //GC.Collect(); //Console.WriteLine("done."); int nc = 0; lock (this) nc = --numConnections; if (stopping && nc == 0) Shutdown(); } }); } }