erizet/EventSource4Net — pull request #1 by Hcu (2013-12-09 14:56:41+00:00)
Title: fixed an issue where the Received event is fired twice because of newline characters

Hi!

I think I have fixed an issue with the code.
A Server sent event terminates with an empty line.

So for example if the server sends the following event: "data: serverdata\n\n", the code would split up the lines and we would get a list of 3 strings:
"data: serverdata" and 2 times the string "\n".

Because of this the code would fire the msgReceived event twice, one for each newline found (line 46 in original code).
If you debug your original sample code, you would see that you would get the same message twice.

I've changed the code to handle this by stripping all the newlines and simply send a msgReceived if the 'sse' object is not null after all the lines have been processed. This way you should only get the event once.

Thanks !!