api.taskController.streaming(data,jobId,apiKey, function(error, success){
if(error)
next(error);
else {
//data.response.success = success;
//data.connection.sendMessage(success);
next(null,success);
}
});
}
streaming : function(data,jobId, apiKey, next) {
console.log("In streaming......"+apiKey+":"+jobId);
subscriber.subscribe("channel:"+apiKey+":"+jobId);
data.connection.rawConnection.responseHeaders.push(['Connection', 'keep-alive']);
data.connection.rawConnection.responseHeaders.push(['Transfer-Encoding', 'chunked']);
data.connection.rawConnection.responseHeaders.splice(0,1);
data.connection.rawConnection.responseHeaders.push(['Content-Type', 'text/event-stream']);
subscriber.on("message", function(channel, message) {
console.log("Message on channel '" + channel + "' arrived!");
console.log(message);
*******here the required message is coming but I am unable to send it as a event/stream response in the client side*************
api.chatRoom.broadcast(data.connection, channel, message, next)
//data.connection.sendMessage(message);
//next(null,message);
});
I have already published the mesasge using publisher.publish("channel:"+apiKey+":"+jobId,JSON.stringify(payload));