Ejemplo n.º 1
0
 private void AcceptConnection(IAsyncResult iAsyncResult)
 {
     lock (_connections)
     {
         var client  = _tcpListener.EndAcceptSocket(iAsyncResult);
         var session = new ServerSession(this, client);
         if (_connections.Count >= Settings.Limit)
         {
             return;
         }
         if (ConnectionsByAddress(session.Address) > Settings.LimitPerAddress)
         {
             return;
         }
         if (_connections.TryAdd(session, session.Address))
         {
             Accept(session);
         }
     }
     _tcpListener.BeginAcceptTcpClient(AcceptConnection, null);
 }
Ejemplo n.º 2
0
 public virtual void Close(ServerSession session)
 {
     Logging.Server($"Closed connection: {session.Address}");
 }
Ejemplo n.º 3
0
 public virtual void Accept(ServerSession session)
 {
     Logging.Server($"New connection: {session.Address}");
 }