Hello,
I'm sure you are right, I'm just learning POE.
The basic problem is that I run a POE::Component::Server::SimpleHTTP
from which I would like to dispatch some URIs to given events.
The idea is something like this:
if you pull http://webserver/module_command
then a module_command event fires.
The problem here is that the dispatcher is registered into SimpleHTTP as
DIR '.*', so it gets everything, but it should somehow tell if
module_command doesn't exist and give back a 404...
On 2007.09.14. 15:25, Nicholas Perez wrote:
Can you describe the situation in which the target session won't
exist? Or describe why a particular event on your target session
wouldn't exist? It would be easier to test for existence of the
session rather than the event on the session (unless of course the
session dynamically alters its events on the fly).
Testing for the existence of a session is easy. From POE::Kernel:
The post() method returns a boolean value indicating whether the event
was enqueued successfully. $! will explain why the post() failed:
ESRCH: The SESSION did not exist at the time of the post() call.
If the events are really that dynamic, and you want to base behavior
around that, you can always use POE::API::Peek:
http://search.cpan.org/~sungo/POE-API-Peek-1.0802/lib/POE/API/Peek.pm#session_event_list
But really, this sounds like an XY problem that could be solved
without "peeking" into the guts of POE.
HTH,
nperez
On 9/14/07, Attila Nagy <[EMAIL PROTECTED]> wrote:
Hello,
I would like to post data to different events, depending on the input.
If the target event doesn't exist, I should process the request locally,
but I don't know any ways to check the existence of an event.
What I would like to do:
if ($_[KERNEL]->event_exists($session, $event_name)) {
$_[KERNEL]->post($session, $event_name, $args);
} else {
do something else
}
How should I do that?
Thanks,