+my $pub = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT}, on_error => sub { warn @_ } );
+my $sub = AnyEvent::Redis->new( host => $ENV{REDIS_HOST}, port => $ENV{REDIS_PORT}, on_error => sub { warn @_ } );
+
+our $contacts;
+
+$sub->psubscribe( 'channel *', sub {
+ my ( $message, $from ) = @_;
+ return unless $from !~ m/\Q$jid\E/; # skip our messages
+ Encode::_utf8_on($message);
+ warn "#Q<< ", dump( $from, $message );
+ my ( undef, $channel, $user ) = split(/ /,$from,3);
+warn "# contacts ",dump($contacts);
+ foreach my $contact ( keys %$contacts ) {
+ next if $from =~ m/\Q$contact\E/;
+ warn "# $jid [$from] -> [$contact] | $message\n";
+ $cl->send_message( join(' ',$channel, $user, $message), $contact => $jid, 'chat' );
+ }
+});