leostereo has asked for the wisdom of the Perl Monks concerning the following question:
Hi guys , Im trying to combine two libraries:
File::Tail and Net::WebSocket::Server. This what I have so far:
#!/usr/bin/perl use File::Tail; use Net::WebSocket::Server; my $file = File::Tail->new( name =>'./test.log', interval => 1, maxinterval => 1, ); Net::WebSocket::Server->new( listen => 8080, on_connect => sub { my ($serv, $conn) = @_; $conn->on( utf8 => sub { my ($conn, $msg) = @_; while (defined(my $line=$file->read)) { $conn->send_utf8('line :'.$line); } }, ); }, )->start;
my client test is:
websocat ws://0.0.0.0:8080But nothing is on the output.Any ideas ?
btw, doing:it works.tail -f test.log 2>&1 | websocat -s 8080 (on the server) and websocat ws://0.0.0.0:8080
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: tail file and websocket stream
by jimpudar (Pilgrim) on Nov 03, 2018 at 18:43 UTC | |
|
Re: tail file and websocket stream
by jimpudar (Pilgrim) on Nov 03, 2018 at 19:24 UTC | |
by leostereo (Beadle) on Nov 08, 2018 at 19:09 UTC | |
|
Re: tail file and websocket stream
by zentara (Cardinal) on Nov 03, 2018 at 20:43 UTC | |
|
Re: tail file and websocket stream
by ForgotPasswordAgain (Vicar) on Nov 03, 2018 at 14:40 UTC | |
by leostereo (Beadle) on Nov 07, 2018 at 15:09 UTC |