diff --git a/lib/CF/Controller/Program.pm b/lib/CF/Controller/Program.pm index a526154b77dd83cbc9149b20d305a49a578b7f57..311ad344d5d6883e665112e32d6d6ef31091a6d0 100644 --- a/lib/CF/Controller/Program.pm +++ b/lib/CF/Controller/Program.pm @@ -34,7 +34,8 @@ sub update ($c) { return $c->error(404, 'Program entry not found') if ! $entry; my $update = $c->prepare_update_data( $entry, $c->req->json ); - my $pubsub = Mojo::Pg::PubSub->new(pg => $c->pg); +# PG_PUBSUB +# my $pubsub = Mojo::Pg::PubSub->new(pg => $c->pg); my $guard = $c->schema->txn_scope_guard; # muze byt jen jeden aktualni bod programu @@ -46,7 +47,7 @@ sub update ($c) { $entry->update( $update ); - $pubsub->json('notify')->notify( notify => { + $c->redis->pubsub->json('notify')->notify( notify => { event => 'program_entry_changed', payload => { id => $entry->id, @@ -54,6 +55,15 @@ sub update ($c) { } }); +# PG_PUBSUB +# $pubsub->json('notify')->notify( notify => { +# event => 'program_entry_changed', +# payload => { +# id => $entry->id, +# %{ $update }, +# } +# }); + $guard->commit; $c->render(status => 204, text => ''); diff --git a/lib/CF/Controller/Websockets.pm b/lib/CF/Controller/Websockets.pm index 9600e85b0015ca2ce3bef3806dbf5563ead723e9..41746d2192ea575d7c5a7dafc63ac5c7c67aa920 100644 --- a/lib/CF/Controller/Websockets.pm +++ b/lib/CF/Controller/Websockets.pm @@ -22,11 +22,16 @@ sub main { $c->res->headers->add('Sec-WebSocket-Extensions' => 'permessage-deflate'); } - my $pubsub = Mojo::Pg::PubSub->new(pg => $c->pg); - - $pubsub->listen(notify => sub($pubsub, $payload) { - $c->send($payload); - }); + $c->redis->pubsub->json('notify')->listen( + notify => sub($pubsub, $payload) { + $c->send($payload); + } + ); +# PG_PUBSUB +# my $pubsub = Mojo::Pg::PubSub->new(pg => $c->pg); +# $pubsub->listen(notify => sub($pubsub, $payload) { +# $c->send($payload); +# }); $c->on(json => sub( $c, $message ) { if ( $message->{event} eq 'KEEPALIVE' ) { @@ -98,7 +103,9 @@ sub main { }); $c->on(finish => sub ($c, $code, $reason = undef) { - $pubsub->unlisten('notify'); +# PG_PUBSUB +# $pubsub->unlisten('notify'); + $c->redis->pubsub->unlisten('notify'); $c->app->log->debug("WebSocket closed with status $code"); }); }