@Override
    public void run() {
        try {
            while (true) {
                int len = in.read(buf);
                if (len == -1) {
                    // System.out.println("INFO: Connection lost.");
                    return;
                }

                byte[] data = new byte[len];
                System.arraycopy(buf, 0, data, 0, len);
                cl.onCommand(this, Command.decode(data));
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                shutdown();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    }