def METHOD_NAME(self, command, event_stream_type, message=None):
    """Send command request and collect and return all emitted events.
    :param command: command to send
    :type command: str
    :param event_stream_type: event type emitted on command execution
    :type event_stream_type: str
    :param message: message (optional)
    :type message: str
    :return: generator for streamed event responses as dict
    :rtype: generator
    """
    if message is not None:
        message = Message.serialize(message)
    self._register_unregister(event_stream_type, True)
    try:
        packet = Packet.request(command, message)
        self.transport.send(packet)
        exited = False
        while True:
            response = Packet.parse(self.transport.receive())
            if response.response_type == Packet.EVENT:
                if not exited:
                    try:
                        yield Message.deserialize(response.payload)
                    except GeneratorExit:
                        exited = True
            else:
                break
        if response.response_type == Packet.CMD_RESPONSE:
            command_response = Message.deserialize(response.payload)
        else:
            raise SessionException(
                "Unexpected response type {type}, "
                "expected '{response}' (CMD_RESPONSE)".format(
                    type=response.response_type,
                    response=Packet.CMD_RESPONSE
                )
            )
    finally:
        self._register_unregister(event_stream_type, False)
    # evaluate command result, if any
    if "success" in command_response:
        if command_response["success"] != b"yes":
            raise CommandException(
                "Command failed: {errmsg}".format(
                    errmsg=command_response["errmsg"].decode("UTF-8")
                )
            )