Exemplo n.º 1
0
        /// <summary>
        /// Calling this function starts the TCP listener, and allows FTP Connections to be made.
        /// </summary>
        public void Start()
        {
            // Init clients list.
            Clients = new List <Client>();

            TcpListener.Start();

            ListenerThread = new Thread(() =>
            {
                Log("Started FTP Server, listening for incoming connections.", "Log");

                while (true)
                {
                    var newClient = new Client(this, TcpListener.AcceptTcpClient());

                    Clients.Add(newClient);

                    ClientJoinedArgs args = new ClientJoinedArgs()
                    {
                        NewClient = newClient
                    };

                    OnClientJoin(args);
                }
            });

            ListenerThread.Name = "TCP Listener thread.";
            ListenerThread.Start();

            Log("Started TCP Listener thread.", "Log");
        }
Exemplo n.º 2
0
        protected virtual void OnClientJoin(ClientJoinedArgs e)
        {
            EventHandler <ClientJoinedArgs> handler = ClientJoined;

            if (handler != null)
            {
                handler(this, e);
            }
        }