I'm using nodeJS with redis as a data store and am running into a problem. I have a redis channel set up that my HTML5 app subscribes to via Server Sent Events, but when I publish from the nodejs server to the channel some text that contains newlines, only the first line is gotten by the client.
I'm new to nodeJS/redis so in all likelihood I'm just doing something dumb. It would be hard to replicate all the code here, but in short, I'm doing something to the effect of:
// in the nodejs setup & controller
client = redis.createClient();
msg = "This is a test.\n\nAnd this is another.";
client.publish("mychannel", msg);
// on the client side javascript file
source = new EventSource('/main/stream')
source.addEventListener('mychannel', function(e) {
$('#messages').append(e.data);
}, false);
What I see from this in my #messages div is "This is a test" but never "And this is another". Is there some parameter I have to give to publish() to make it do newlines?
I did try replacing the newlines before publishing to the channel... but I'd rather keep them there for readability; besides, that is attacking the symptom not the disease.
Thanks!
Maybe worth a try:
var nl = '\n'.charCodeAt(0);
msg = "This is a test."+nl+nl+"And this is another.";
as seen here http://hermanjunge.com/post/10634913617/redis-nodejs-dump-txt-into-db