Skip to content
Browse files

die() rather than confess() in _create_connector

  • Loading branch information...
1 parent 7eba5de commit 57cfdaf546306127597a123a6c4ec85edfc6b921 @avenj committed Mar 23, 2013
Showing with 34 additions and 32 deletions.
  1. +14 −9 README.mkdn
  2. +20 −23 lib/POEx/IRC/Backend.pm
View
23 README.mkdn
@@ -11,22 +11,27 @@ POEx::IRC::Backend - IRC client or server backend
my $backend = POEx::IRC::Backend->spawn;
$poe_kernel->post( $backend->session_id, 'register' );
+ sub ircsock_registered {
+ my ($kernel, $self) = @_[KERNEL, OBJECT];
+
## Listen for incoming IRC traffic:
$backend->create_listener(
bindaddr => $addr,
port => $port,
);
- $backend->create_connector(
- remoteaddr => $remote,
- remoteport => $remoteport,
- ## Optional:
- bindaddr => $bindaddr,
- ipv6 => 1,
- ssl => 1,
- );
+ ## Connect to a remote endpoint:
+ $backend->create_connector(
+ remoteaddr => $remote,
+ remoteport => $remoteport,
+ ## Optional:
+ bindaddr => $bindaddr,
+ ipv6 => 1,
+ ssl => 1,
+ );
+ }
- ## Handle and dispatch incoming IRC events.
+ ## Handle and dispatch incoming IRC events:
sub ircsock_input {
my ($kernel, $self) = @_[KERNEL, OBJECT];
View
43 lib/POEx/IRC/Backend.pm
@@ -1,10 +1,4 @@
package POEx::IRC::Backend;
-
-## TODO
-# - try-catch all errors and dispatch them as events?
-# (with optional debug warnings?)
-# should apply to any die in an event handler preferably
-
use 5.10.1;
use strictures 1;
@@ -227,9 +221,7 @@ sub _register_controller {
$kernel->refcount_decrement( $self->controller, "IRCD Running" )
if $self->has_controller;
-
$self->_set_controller( $_[SENDER]->ID );
-
$kernel->refcount_increment( $self->controller, "IRCD Running" );
$kernel->post( $self->controller =>
@@ -484,7 +476,7 @@ sub _create_connector {
my $remote_addr = delete $args{remoteaddr};
my $remote_port = delete $args{remoteport};
- confess "_create_connector expects a RemoteAddr and RemotePort"
+ die "create_connector expects a RemoteAddr and RemotePort"
unless defined $remote_addr and defined $remote_port;
my $protocol = 4;
@@ -821,22 +813,27 @@ POEx::IRC::Backend - IRC client or server backend
my $backend = POEx::IRC::Backend->spawn;
$poe_kernel->post( $backend->session_id, 'register' );
- ## Listen for incoming IRC traffic:
- $backend->create_listener(
- bindaddr => $addr,
- port => $port,
- );
+ sub ircsock_registered {
+ my ($kernel, $self) = @_[KERNEL, OBJECT];
- $backend->create_connector(
- remoteaddr => $remote,
- remoteport => $remoteport,
- ## Optional:
- bindaddr => $bindaddr,
- ipv6 => 1,
- ssl => 1,
- );
+ ## Listen for incoming IRC traffic:
+ $backend->create_listener(
+ bindaddr => $addr,
+ port => $port,
+ );
+
+ ## Connect to a remote endpoint:
+ $backend->create_connector(
+ remoteaddr => $remote,
+ remoteport => $remoteport,
+ ## Optional:
+ bindaddr => $bindaddr,
+ ipv6 => 1,
+ ssl => 1,
+ );
+ }
- ## Handle and dispatch incoming IRC events.
+ ## Handle and dispatch incoming IRC events:
sub ircsock_input {
my ($kernel, $self) = @_[KERNEL, OBJECT];

0 comments on commit 57cfdaf

Please sign in to comment.
Something went wrong with that request. Please try again.