#!/usr/bin/env perl #---AUTOPRAGMASTART--- use v5.36; use strict; use diagnostics; use English qw(-no_match_vars); use Carp qw[carp croak confess cluck longmess shortmess]; our $VERSION = 29; use autodie qw( close ); use Array::Contains; use utf8; use Encode qw(is_utf8 encode_utf8 decode_utf8); use Data::Dumper; #---AUTOPRAGMAEND--- use Net::Clacks::Client; use Time::HiRes qw(sleep); my $username = 'exampleuser'; my $password = 'unsafepassword'; my $applicationname = 'debugmonitor'; my $keepRunning = 1; $SIG{TERM} = sub{ print "SIGTERM, exiting program\n"; $keepRunning = 0; }; # Client side caching is a whole other topic. Basically, it doesn't resend stuff when the value hasn't changed # In most cases this isn't required or can even be counter-productive. This is one of those advanced topics... my $is_caching = 0; # Let's connect my $debug = Net::Clacks::Client->newSocket('example.sock', $username, $password, $applicationname, $is_caching) or croak("Connection to server failed"); # If you want to use TCP, you can do this instead: #my $debug = Net::Clacks::Client->new('127.0.0.1', 49888, $username, $password, $applicationname, $is_caching); $debug->setMonitormode(1); # NSA mode activate ;-) $debug->disablePing(); # Disable ping timeouts $debug->doNetwork(); # Send buffered commands to server while($keepRunning) { $debug->doNetwork(); # Sync with server # Iterate over all messages in our in-buffer while((my $msg = $debug->getNext())) { if($msg->{type} eq 'debug') { print $msg->{host}, ": ", $msg->{command}, "\n"; } elsif($msg->{type} eq 'serverinfo') { print '+++ Connected to server version: ', $msg->{data}, "\n"; } elsif($msg->{type} eq 'disconnect') { print '+++ Disconnected by server, reason given: ', $msg->{data}, "\n"; last; } } sleep(0.2); } $debug->disconnect(); exit(0);