示例#1
0
        public async void StartHost()
        {
            if (Main == null)
            {
                throw new InvalidOperationException(" 'Main' was null!");
            }

            server.Start();

            while (true)
            {
                var socket = await server.AcceptSocketAsync();

                var session = new TelnetSession(this, socket);
                _sessions.Add(session.ConnectionId, session);

                var e = new SessionEventArgs(session);  //todo: this client event can block the whole server
                SessionConnected?.Invoke(this, e);

                if (!e.RefuseConnection)
                {
                    session.Run();
                }
                else
                {
                    session.Kick();
                }
            }
        }
        internal TelnetTerminal(TelnetSession session)
        {
            Session = session;

            ANSI_Decoder          = new ANSI_Decoder();
            ANSI_Decoder.KeyReady = (key) => this.ProcessKey(key);
        }
示例#3
0
        internal void ClientDisconnected(TelnetSession session)
        {
            var e = new SessionEventArgs(session);

            SessionDisconnected(this, e);

            _sessions.Remove(session.ConnectionId);
        }