Ejemplo n.º 1
0
        public async Task Start(int port)
        {
            server = new TcpListener(ip, port);
            server.Start();

            IsWorking = true;
            while (IsWorking)
            {
                try
                {
                    var client = await server.AcceptTcpClientAsync();

                    var session = new ServerSession(client, processor);
                    sessions.Add(session);
                    ConnectionQuantityChanged?.Invoke(this, new EventArgs());
                    session.Start();
                }
                catch
                {
                    IsWorking = false;
                }
            }
        }
Ejemplo n.º 2
0
 private void Session_ConnectionClosed(object sender, EventArgs e)
 {
     sessions.Remove(sender as ServerSession);
     ConnectionQuantityChanged?.Invoke(this, new EventArgs());
 }