private async Task AcceptLoop() { _listener.Start(); while (true) { TcpClient tcpClient = await _listener.AcceptTcpClientAsync(); // connection established; build a client object Client client = new Client { TcpClient = tcpClient }; // set up a repl NetworkStream stream = tcpClient.GetStream(); TextReader r = new StreamReader(stream); TextWriter w = new StreamWriter(stream); ConsoleReplView view = new ConsoleReplView(r, w); Repl repl = new Repl(view, new IronPythonEvaluationContext()); client.Repl = repl; // service the repl client.ServiceTask = Task.Run(() => ServiceLoop(client)); } }
private void ServeLocalInteraction() { while (!_shutdown) { IronPythonEvaluationContext lang = new IronPythonEvaluationContext(); Repl repl = new Repl(new ConsoleReplView(), lang); // HACK: load static scripts so I have something to test repl.LoadScripts(_staticScripts); Task t = repl.Main(); t.Wait(); if (!_shutdown) { Console.Out.WriteLine("!!! local interaction detached; restarting (server.Shutdown() to shut down server)..."); } } }
internal ServerProxy(Repl repl) { this._repl = repl; }