@Override
    public void run() {
        currentThread = Thread.currentThread();
        for (; ; ) {
            if (Thread.currentThread().isInterrupted()) {
                System.out.println("Receiver Thread is interrupted");
                return;
            }
            try {
                Command command = commandReader.read();
                processMessage(command);

            } catch (IOException e) {
                e.printStackTrace();
                try {
                    sendLogoutCommand();
                } catch (InterruptedException e1) {
                    // Restore the interrupted status
                    Thread.currentThread().interrupt();
                }


            } catch (IllegalArgumentException e) {
                // todo replace with logger
                e.printStackTrace();
            } catch (InterruptedException e) {
                // Restore the interrupted status
                Thread.currentThread().interrupt();
            }
        }
    }