@@ -0,0 +1,1503 @@
+package pl.edu.elka.raj;%0A%0Aimport pl.edu.elka.models.Node;%0Aimport pl.edu.elka.util.Log;%0A%0Aimport java.io.BufferedReader;%0Aimport java.io.InputStreamReader;%0Aimport java.net.Socket;%0A%0A/**%0A * Represents a client connected to the TCP server and manages its lifecycle%0A *%0A * @author Gregorio%0A *%0A */%0Apublic class TCPClientWorker implements Runnable%0A%7B%0A    private Node client;%0A%0A    public TCPClientWorker(Node client)%0A    %7B%0A        this.client = client;%0A    %7D%0A%0A    /*%0A     * Implementation of the run method that handles client communication and%0A     * connection/disconnection.%0A     *%0A     * @see java.lang.Runnable#run()%0A     */%0A%0A    public void run()%0A    %7B%0A        while (!client.getSocket().isClosed())%0A        %7B%0A            try%0A            %7B%0A                BufferedReader inFromClient = new BufferedReader(new InputStreamReader(client.getSocket().getInputStream()));%0A                String data = inFromClient.readLine();%0A                if (data == null) %7B%0A                    return;%0A                %7D%0A                NetworkController.processMessage(client, data);%0A            %7D%0A            catch (Exception e)%0A            %7B%0A                try%0A                %7B%0A                    client.getSocket().close();%0A                %7D%0A                catch (Exception ex)%0A                %7B%0A                %7D%0A                Log.LogError(Log.SUBTYPE.SYSTEM, %22Client disconnected%22);%0A            %7D%0A        %7D%0A%0A        NetworkController.clients.remove(client.getPid());%0A        NetworkController.election();%0A    %7D%0A%0A%7D%0A

Create TCPClientWorker.java