I playing around with ntfy.sh, looking for a way to subscript to messages and execute code based on the content. I found the solution for json stream but websockets stops printing after a few messages or a short time. Any idea why? here is the code:
submitted by /u/ktown007
[link] [comments]
use v5.40 ; use IO::Async::Loop; use Net::Async::WebSocket::Client; my $client = Net::Async::WebSocket::Client->new( on_text_frame => sub( $self, $frame ) { print $frame ; }, ); my $loop = IO::Async::Loop->new; $loop->add( $client ); $client->connect( url => "wss://ntfy.sh/perl/ws" )->get ; $loop->run;
submitted by /u/ktown007
[link] [comments]