@Override
    public void run() {
        try {
            while (running) {
                Message m = messages.take();
                String message = m.getMessage();
                int command = Protocol.CheckMessage.registrerProtocolType(message);
                switch (command) {
                    case 1:
                        connect(m);
                        break;
                    case 2:
                        send(m);
                        break;
                    case 3:
                        close(m);
                        break;
                    default:
                        Logger.getLogger(ClientHandler.class.getName()).log(Level.INFO, ("invalid message: " + message));
                }
            }
        } catch (InterruptedException ex) {
            Logger.getLogger(ClientHandler.class.getName()).log(Level.INFO, ex.toString());
        }
    }