Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: IRC Client not Joining Channel

by assemble (Friar)
on Mar 04, 2008 at 17:35 UTC ( [id://671951]=note: print w/replies, xml ) Need Help??


in reply to Re^2: IRC Client not Joining Channel
in thread IRC Client not Joining Channel

I recommend cutting out all the extra code next time, it is very distracting from the actual problem. So here is the code that you say appears to be bad
#-------------------Watch for IRC Inputs------------------- sub incoming_data { my ( $fd, $condition, $fh ) = @_; print "its going\n"; if ( $condition eq 'in' ) { my $input; sysread $fh, $input, 1000000; #chop $input; $input =~ s/\r\n//g; my $hashref = $parser->parse( $input ); SWITCH: { my $type = lc $hashref->{command}; my @args; push @args, $hashref->{prefix} if $hashref->{prefix}; push @args, @{ $hashref->{params} }; if ( defined $dispatch{$type} ) { $dispatch{$type}->(@args); last SWITCH; } print STDOUT join( ' ', "irc_$type:", @args ), "\n"; } } return 1; }
First, I recommend changing:
sysread $fh, $input, 1000000; #chop $input; $input =~ s/\r\n//g;
to:
$input = <$fh>; chomp $input;
You can put a loop in there if you want to handle more than one line at a time. What you are doing mushes everything together and makes it unparseable.

Replies are listed 'Best First'.
Re^4: IRC Client not Joining Channel
by deadpickle (Pilgrim) on Mar 04, 2008 at 19:47 UTC
    It seems that the Gtk2::Helper is not running after the connection is made. The print in incoming_data "im going" does not appear so it seems like the Helper is not working.
    sub connecting { # Connect to the IRC server. $sock = new IO::Socket::INET( PeerAddr => $irc, PeerPort => 6667, Proto => 'tcp', ) or die "Can't connect\n"; print "hello\n"; $watch = Gtk2::Helper->add_watch( fileno $sock, 'in', \&incoming_d +ata, $sock ); # Log on to the server. print $sock "NICK $nick\r\n"; print $sock "USER $login 8 * :CoCoNUE Member\r\n"; $chat_entry->set_editable(1); $chat_entry->grab_focus; #chat_entry->signal_handler_unblock ($chat_send_sig); return 1; }

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://671951]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found