/// <summary> /// creates a new handler for each clients and starts to handle them /// </summary> /// <param name= client> the client to handle </param> protected override void communicate(TcpClient client) { new Task(() => { IClientHandler handler = new ClientHandler(controller, logging); handler.CommandRecieved += NewCommand; handler.HandleClient(client, locker); }).Start(); }
/// <summary> /// This function handles a cliet that connetes to the server. /// </summary> /// <param name="client">The TcpClient that connected to the server.</param> public void HandleClient(TcpClient client) { // Creates a new client handler and let it handle the client ClientHandler clientHandler = new ClientHandler(this.controller, this.logging); // Make the current client tell the clientManager when it closed clientHandler.ClientClosed += this.OnClientClosed; // Make the client recive logs. this.logging.MessageRecieved += clientHandler.ReciveLog; //Make the client get notification when a handler is closed. foreach (DirectoyHandler dirHandler in this.handlersList) { dirHandler.DirectoryClose += clientHandler.OnDirectoryClose; clientHandler.CommandRecieved += dirHandler.OnCommandRecieved; } clientHandler.HandleClient(client); }