示例#1
0
        public void SendDetach(ScriptConsoleClient src)
        {
            var evt = new ScriptConsoleEvent();

            evt.Cmd       = null;
            evt.Type      = ScriptConsoleEvent.EventType.DetachClient;
            evt.SrcClient = src;
            Clientq.Add(evt);
        }
示例#2
0
        public void SendCmd(ScriptConsoleClient src, string cmd)
        {
            var evt = new ScriptConsoleEvent();

            evt.Cmd       = cmd;
            evt.Type      = ScriptConsoleEvent.EventType.ProcessCmd;
            evt.SrcClient = src;
            Clientq.Add(evt);
        }
示例#3
0
        void OnClientConnect(IAsyncResult ar)
        {
            if (!IsListening)
            {
                return;                     // refuse new connections if in the process of closing
            }
            // accept the connection and add it to the list of clients
            var       listener     = (TcpListener)ar.AsyncState;
            TcpClient newTcpClient = listener.EndAcceptTcpClient(ar);
            var       newClient    = new ScriptConsoleClient(newTcpClient, this);

            Client.Add(newClient);
            Trace.WriteLine(string.Format("ScriptConsole added client at {0}:{1}", newClient.IpAddr, newClient.Port));

            // start listening for input from the new client
            newClient.BeginRead();
            newClient.BeginWrite("Attached to console");

            // listen for the next connection
            Console.BeginAcceptTcpClient(OnClientConnect, Console);
        }