I'll ditto that -- I've had the same issue with PoCo::Client::TCP.
In several occasions while using it within a new component, having to use
inline subs as closures to get parameters passed into the new session.
I've gone to the docs several times looking for a Heap parameter, and
not finding one.

I'm also a relative begginer to POE, so let me know if there's some
other way I should be doing things...

Rob

On Sat, Nov 23, 2002 at 12:34:37PM +0000, Pedro Melo CUNHA wrote:
> 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
> 

-- 
Rob Fugina, Systems Guy
[EMAIL PROTECTED] -- http://www.geekthing.com
My firewall filters MS Office attachments.

Give a man a fish and he will eat for a day. Teach him to
fish and he'll sit in a boat and drink beer all day.

Reply via email to