Howdy,
I'm writing SMTP client component. It's working ok, but "it feels odd".
I'm using the PoCo::Client::DNS framework: you spawn a MUA session, other
sessions can send_mail event's to it, and get back the results via
postback's.
So far so good. But being a lazy person, I wrote the SMTP client with
PoCo::Component::Client::TCP. The problem is that this component does not
lend itself easilly to reuse by other components.
I need to stuff into the Client::TCP head the session_id of the original
sender, or at least, the session id of the MUA, but there is no way to do
it, so it seem's.
Rigth now, I'm using closures so that the ClientDisconnect event can find
the MUA session_id/alias.
Basically, my handler_send_mail looks like this:
sub handle_send_mail {
my ($kernel, $heap, $sender) = @_[ KERNEL, HEAP, SENDER ];
my %a = @_[ ARG0..$#_ ];
my $sender_id = $sender->ID;
$heap->{postback}{$sender_id} = $sender->postback( $a{reply_to}, %a );
my $server = $a{smtp_server} || $heap->{server};
my $port = $a{smtp_port} || $heap->{port};
my $message = $a{message};
my $alias = $heap->{alias};
POE::Component::Client::TCP->new(
RemoteAddress => $server,
RemotePort => $port,
Disconnected => sub {
my ($kernel, $heap) = @_[ KERNEL, HEAP ];
$kernel->post( $alias => result => $sender_id => $heap->{result} );
},
ServerInput => sub {
my ($heap, $data) = @_[ HEAP, ARG0 ];
# SMTP protocol here...
},
);
}
Instead, I would like to be able to pass a Args or a Heap parameter to
Client::TCP that I could see in my handler's...
I'm a beginer in POE, so I migth be on the wrong path... If the Args or
Heap argument to Client::TCP is interesting for someone, I can send you a
patch.
Best regards,
--
Pedro Melo Cunha - <[EMAIL PROTECTED]>
Novis Telecom, S.A. - Dir. Rede - ISP <http://www.novis.pt/>
Edif�cio Novis - Estrada da Outurela, 118 - 2795-606 Carnaxide
tel: +351 21 0104340 - fax: +351 21 0104301
- Re: Using PoCo::Client::TCP in a new Component Pedro Melo CUNHA
- Re: Using PoCo::Client::TCP in a new Component Rob Fugina
- Re: Using PoCo::Client::TCP in a new Component Pedro Melo CUNHA
- Re: Using PoCo::Client::TCP in a new Compone... Rocco Caputo
