--- Net-Knuddels/eg/knuddel 2005/01/13 00:56:02 1.1 +++ Net-Knuddels/eg/knuddel 2005/01/13 02:28:42 1.2 @@ -1,27 +1,17 @@ #!/usr/bin/perl + use strict; + +use Event; use Net::Knuddels; -use IO::Socket; -use IO::Handle; -use IO::Socket::INET; - -sub new_socks { - my ($host, $port) = @_; - - my $s = IO::Socket::INET->new ( - PeerAddr => $host, - PeerPort => $port, - Proto => 'tcp' - ); - die "Couldn't make socket to ${host}:${port}: $!\n"; -} +my $knudi = new Net::Knuddels::Client PeerAddr => "213.61.5.150:2710"; -my $knudi = Net::Knuddels::Protocol->new (); +$knudi->login; my %channels; -$knudi->register ('b' => sub { +$knudi->register (b => sub { for (@_) { if ($_ ne "-") { @@ -32,15 +22,18 @@ } }); -my $sock = new_socks ($ARGV[0], $ARGV[1]); +$knudi->register (ALL => sub { + use Dumpvalue; + print "---\n"; + Dumpvalue->new (compactDump => 1, veryCompact => 1, quoteHighBit => 1, tick => '"')->dumpValue ([@_]); +}); + +$knudi->register (login => sub { + $knudi->set_nick ("Zwickau", "Net-Knuddels", "lolfe"); +}); + +Event->io ( fd => $knudi->fh, poll => 'r', cb => sub { $knudi->ready }); -my $clw = Event->io ( - fd => $sock, - poll => 'r', - cb => sub { - my $data; - $sock->sysread ($data, 1000); - $knudi->feed_data ($data); - }); +Event::loop;