如何向Ajax Chat添加更多频道? 我的问题是,无论我在/chat/lib/data/channels.php中所做的更改,聊天界面向我显示的唯一渠道是"用户"一个
我的channels.php文件
sub startup{
...
###################### Redis part
$self->helper(
redis => sub {
state $redis = Mojo::Redis2->new(server => '127.0.0.1:6379');
}
);
$self->redis->on(message => sub {
my ($redisself, $message, $channel) = @_;
# PROBLEM: on morbo this is blocking
# PROBLEM: on hypnotoad this works only sometimes
# - e.g., for the first time after hot deployment restart
say "DEQUEUE: $message @ $channel";
sleep (10); # replaces long-running operation
say "FINISHED processing: $message @ $channel";
});
$self->redis->subscribe(['long_running_tasks'] => sub {
my ($rself, $err, $res) = @_;
say "SUBSCRIBED to channel long_running_tasks";
});
$self->redis->on(connection => sub {
my ($self, $info) = @_;
say "got redis connection id: $info->{id}, group: $info->{group}, nblocking: $info->{nb}.";
});
$self->redis->on(error => sub {
my ($self, $err) = @_;
say "got redis error $err";
});
######################## Redis part END
...
# route
$manager->get('/regenerate')->to('controller#regenerate');
}
#######################
# in the Controller.pm
#######################
sub regenerate {
my $self = shift;
$self->redis->publish("long_running_tasks" => "regenerate");
$self->flash(
msg_type => 'info',
msg => 'Regeneration of will be executed in background.'
);
$self->redirect_to($self->get_referrer());
}
我总是只看到用户频道。为什么?
提前致谢
答案 0 :(得分:0)
您需要编辑/ lib / data文件夹下的users.php并包含以下内容
$users[1]['channels'] = array(0,1,2,3,4,5,6,7,8,9,10);
在上面0到10中是用户的频道权限
此致 纳拉亚南