0

I am using PHP_redis on windows to connect to redis and I am trying to create a simple chat app using publish and subscription command. The publish command works fine and I am able to see messages using redis-cli.exe , but I am not able to get it through Php. But the subscribe.php files keeps loading and never return any messages. Below is script that I am using for subscribe.php file

<?php

//subscribe.php

function f($redis, $chan, $msg) {
    switch($chan) {
        case 'chan-1':
            echo "get $msg from $chan\n";
            break;
        case 'chan-2':
            echo "get $msg FROM $chan\n";
            break;
        case 'chan-3':
            break;
    }
}

ini_set('default_socket_timeout', -1);

$redis = new Redis();
$redis->pconnect('127.0.0.1',6379);

$redis->subscribe(array('chan-1', 'chan-2', 'chan-3'), 'f');

?>
Nadir
  • 126
  • 1
  • 11

0 Answers0