On (02/24 11:20), Exide Arabellan wrote:
When printing a line to the users console...
$poe_kernel->post( $user => send => "message" );
using what module? what code? the 'send' event there could be anyone's code from anywhere. kinda hard to debug from here :)
-- Matt Cashner http://eekeek.org eek at eekeek dot org
Oops :) I know better than that. I took it from the Simple Chat Server example in the POE Cookbook on poe.perl.org. It uses POE::Component::Server::TCP.
Here is the code... --- package POE::Server::MUD::MassiveMUD;
use strict; use warnings; use vars qw($VERSION @ISA @EXPORT $dbh); use DBI; use POE; use POE::Component::Server::TCP; require Exporter;
@ISA = qw(Exporter AutoLoader); @EXPORT = qw(); $VERSION = '0.01';
sub new { my $class = shift; my %args = @_; return bless \%args, $class; }
sub run { my $self = shift;
$dbh = DBI->connect( 'DBI:mysql:'.$self->{'SQLDB'}, $self->{'SQLUser'}, $self->{'SQLPass'}, { RaiseError => 1, AutoCommit => 1 } ) || die "Error: ".$DBI::errstr;
POE::Component::Server::TCP->new( Alias => $self->{'Alias'}, Port => $self->{'Port'}, InlineStates => { send => \&handle_send }, ClientConnected => \&client_connected, ClientError => \&client_error, ClientDisconnected => \&client_disconnected, ClientInput => \&client_input, ); $poe_kernel->run(); exit 0; }
# Prepare global variables my %users;
# Bunch of subroutines edited out for clarity sub client_connected { my $session_id = $_[SESSION]->ID; $poe_kernel->post( $session_id => send => "Username: " ); } # End of editing
1; ---
Exide Arabellan www.arabellan.com