Re: DirWatch and TCP Client
hideo <[email protected]>
| Newsgroups | gmane.comp.lang.perl.poe |
|---|---|
| Message-ID | <[email protected]> |
Jeff Eggen (Wed 08/06/08 13:58): > Hi all, > > I'm very new to this POE stuff, and figured there was someone here who could give me some advice. It seems like an event-driven solution is the way to go about things in this situation, but I don't have much experience with it. > > I have an application that generates messages as files on a filesystem, separating the files into various directories based on their content. My objective is to get those files and send them via tcp to various applications on other hosts. I'm thinking that I would go about this with PoCo::DirWatch and PoCo::Client::TCP, but I'm not sure exactly how best to wire the two together so that I have one client session attached to one directory watcher. > > Can anyone provide advice as to how to tie the event handlers of those two classes together so that a DirWatch session getting an event will somehow inform the appropriate Client::TCP session that it has an event? > Hey Jeff, 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