Re: DirWatch and TCP Client

"Jeff Eggen" <[email protected]>
Newsgroups gmane.comp.lang.perl.poe
Message-ID <[email protected]>
>>> hideo <[email protected]> 06/08/2008 2:51 PM >>>
>We have a few daemons that do just this.  My strategy has been to:
	
>	1) move the new file to a temp directory
>	2) post the file path (and originating directory if necessary)
>	   to a general event
>	3) via a dispatch table the appropriate subroutine to process
>	   the file is invoked.

>1 and 2 happen in the callback.  The relevant path and directory 
>info will be available in the ARGs.

>Has worked like a champ for us.

>Zach

Just to clarify things for my sake: 1 and 2 happen in the DirWatch session's file_callback method?  And the dispatch table is a hash mapping the identifier for each application to a Client::TCP session object?

I'm a little unsure of what you mean with 2 & 3.  I'm thinking that it would be something like this (excuse the rough mock-code):

# Create Client::TCP sessions:

my %dispatch;
foreach ( @queues)
{
	$dispatch{$_} = PoCo::Client::TCP->new();
}

# PoCo::DirWatch object's file_callback method:
sub file_callback
{
	my $file = ...; #read file contents into memory
	my $tag = substr($file, 19, 5); #get the identifier
	$dispatch{$tag}->{server}->put($file); #send $file to server
}

Is this what you mean?

Thanks very much,
Jeff

This e-mail and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed.  If you are not the named addressee, please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail from your system. If you are not the intended recipient you are notified that using, disclosing, copying or distributing the contents of this information is strictly prohibited.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.