aboutsummaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorZoffix Znet <cpan@zoffix.com>2016-06-03 07:01:14 -0400
committerZoffix Znet <cpan@zoffix.com>2016-06-03 07:01:14 -0400
commit0daa494480f7abe37a6e593c6238811009b7b914 (patch)
tree5916cb48581e9478c8b92bb458589940f6fa814e /t
parent495050a801901460fbd6a9c525216612b0d2f470 (diff)
Start rewrite
Diffstat (limited to 't')
-rw-r--r--t/release/servers/01-basic.pl67
1 files changed, 67 insertions, 0 deletions
diff --git a/t/release/servers/01-basic.pl b/t/release/servers/01-basic.pl
new file mode 100644
index 0000000..fe5ea06
--- /dev/null
+++ b/t/release/servers/01-basic.pl
@@ -0,0 +1,67 @@
+# A fairly simple example:
+use strict;
+use warnings;
+use POE qw(Component::Server::IRC);
+
+my %config = (
+ servername => 'simple.poco.server.irc',
+ nicklen => 15,
+ network => 'SimpleNET'
+);
+
+my $pocosi = POE::Component::Server::IRC->spawn( config => \%config );
+
+POE::Session->create(
+ package_states => [
+ 'main' => [qw(_start _default)],
+ ],
+ heap => { ircd => $pocosi },
+);
+
+$poe_kernel->run();
+
+sub _start {
+ my ($kernel, $heap) = @_[KERNEL, HEAP];
+
+ $heap->{ircd}->yield('register', 'all');
+
+ # Anyone connecting from the loopback gets spoofed hostname
+ # $heap->{ircd}->add_auth(
+ # mask => '*@localhost',
+ # spoof => 'm33p.com',
+ # no_tilde => 1,
+ # );
+
+ # We have to add an auth as we have specified one above.
+ $heap->{ircd}->add_auth(mask => '*@*');
+
+ # Start a listener on the 'standard' IRC port.
+ $heap->{ircd}->add_listener(port => 5667);
+
+ # Add an operator who can connect from localhost
+ $heap->{ircd}->add_operator(
+ {
+ username => 'moo',
+ password => 'fishdont',
+ }
+ );
+}
+
+sub _default {
+ my ($event, @args) = @_[ARG0 .. $#_];
+
+ print "$event: ";
+ for my $arg (@args) {
+ if (ref($arg) eq 'ARRAY') {
+ print "[", join ( ", ", @$arg ), "] ";
+ }
+ elsif (ref($arg) eq 'HASH') {
+ print "{", join ( ", ", %$arg ), "} ";
+ }
+ else {
+ print "'$arg' ";
+ }
+ }
+
+ print "\n";
+ }