@Override
    public void run() {
        try {
            InputStream iStream = socket.getInputStream();
            int iType;
            while (!myThread.isInterrupted() && (iType = iStream.read()) > 0) {
                byte type = (byte) iType;
                if (type == MessageType.HELLO.getId()) {
                    getHelloMessage();
                } else if (type == MessageType.BYE.getId()) {
                    getByeMessage();
                } else if (type == MessageType.MESSAGE.getId()) {
                    getMessage();
                } else {
                    getErrorMessage();
                }
            }
        } catch (Throwable t) {
            if (!isClosed) {
                close(true, true);
            }
        }

    }