/// <summary> /// Finalizes the listener operating. /// </summary> protected void FinalizeListener() { DisconnectAll(); tcpListener.Stop(); tcpListener = null; clients = null; protector = null; thread = null; }
/// <summary> /// Prepares the listener for operating. /// </summary> protected void PrepareListener() { tcpListener = new TcpListener(IPAddress.Any, listenerOptions.Port); tcpListener.Start(); clients = new ConcurrentDictionary <long, ConnectedClient>(); protector = new BruteForceProtector(MaxFailsPerMinute, BlockingDuration); protector.BlockedChanged += (object sender, BlockedChangedEventArgs e) => { log.WriteMessage(e.Message, e.Blocked ? LogMessageType.Warning : LogMessageType.Action); }; terminated = false; }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ListenerBase(ListenerOptions listenerOptions, ILog log) { this.listenerOptions = listenerOptions ?? throw new ArgumentNullException(nameof(listenerOptions)); this.log = log ?? throw new ArgumentNullException(nameof(log)); tcpListener = null; clients = null; protector = null; thread = null; terminated = false; CustomFunctions = null; }