ralscha / sse-eventbus

EventBus library for sending events from a Spring appliction to the web browser with SSE
Apache License 2.0
79 stars 26 forks source link

Multi-line message not added correctly #8

Closed smithtonson closed 6 years ago

smithtonson commented 6 years ago

In ClientEvent class lines 57 & 60, a call should be made to sseBuilder.data() for each line in the output. Alternatively, the newline could be removed from convertedValue and this.event.data()

If not removing newlines, I think the code should instead be:

        if (this.convertedValue != null) {
                        for (String line : this.convertedValue.split("\n")) {
                            sseBuilder.data(line);
                        }
        }
        else {
                        for (String line : this.event.data().split("\n")) {
                            sseBuilder.data(line);
                        }
        }

Otherwise only the first line of output is treated as the data line, anything else without a data: prefix on the output is ignored.