Below is a code for redis pubsub in node.js. I publish a binary data after reading a file and a plain text, is there a way to identify if the buffer received on message is binary or text?
var redis = require("redis"),
pub = redis.createClient(null, null, {
detect_buffers: true
}),
sub = redis.createClient(null, null, {
detect_buffers: true
}),
fs = require("fs");
sub.subscribe("abc");
sub.on("subscribe", function(channel, count) {
fs.readFile("IMG_2693.JPG", function(err, data) {
pub.publish("abc", data);
});
pub.publish("abc", "hello");
});
sub.on("message", function(channel, data) {
// Can I identify if it is binary data or text?
console.dir(data);
});
Thanks!