I have a PHP code which publishes data to a channel called "MESSAGE_FROM_MARS". The snippet is as follows :
function send_data_to_check_spam($feedback)
{
$d_id=$this->redis_connect(11);
//echo $feedback;
//die();
echo "<b style='color:red'>MESSAGE SENT TO SPAM SWATTER</b>"."<br>";
$d_id->PUBLISH("MESSAGE_FROM_MARS",$feedback);
}
There is a server side python listener which receives the published data and the snippet is as follows :
r = redis.StrictRedis(host='localhost', port=6379, db=11)
def sum(a,b):
print a+b
def main():
sub = r.pubsub()
sub.subscribe('MESSAGE_FROM_MARS')
The python code does the processing and publishes the result back. The snippet is as follows :
r.publish('SPAM_STATUS',spam)
I am trying to get the result using a socket.io websocket and the snippet is as follows. :
<script>
var socket = io.connect('127.0.0.1:6379');
console.log(socket);
socket.on('SPAM_STATUS', function (data) {
alert("here");
console.log(data);
//socket.emit('my other event', { my: 'data' });
});
</script>
Everything works like a peach except that the socket.io for some reason is not getting the message from the SPAM_STATUS channel.
What am I doing wrong? I am relatively new to socket.io, so pardon my naivety