def METHOD_NAME(self):
    """Waits and returns received messages.
    If running in compatibility mode for older uWSGI versions,
    it also sends messages that have been queued by send().
    A return value of None means that connection was closed.
    This must be called repeatedly. For uWSGI < 2.1.x it must
    be called from the main greenlet."""
    while True:
        if self._req_ctx is not None:
            try:
                msg = uwsgi.websocket_recv(request_context=self._req_ctx)
            except IOError:  # connection closed
                return None
            return self._decode_received(msg)
        else:
            if self.received_messages:
                return self.received_messages.pop(0)
            # we wake up at least every 3 seconds to let uWSGI
            # do its ping/ponging
            event_set = self._event.METHOD_NAME(timeout=3)
            if event_set:
                self._event.clear()
                # maybe there is something to send
                msgs = []
                while True:
                    try:
                        msgs.append(self._send_queue.get(block=False))
                    except gevent.queue.Empty:
                        break
                for msg in msgs:
                    self._send(msg)
            # maybe there is something to receive, if not, at least
            # ensure uWSGI does its ping/ponging
            while True:
                try:
                    msg = uwsgi.websocket_recv_nb()
                except IOError:  # connection closed
                    self._select_greenlet.kill()
                    return None
                if msg:  # message available
                    self.received_messages.append(
                        self._decode_received(msg))
                else:
                    break
            if self.received_messages:
                return self.received_messages.pop(0)