On 24-Apr-2002 Dan McCormick wrote:
> Hi,
> 
> Does anyone have any advice for writing a POE object/session in such a
> way that the main program doesn't need to know all its states?
> 
> The problem is that if you write 20 programs that use one POE
> object/session, and then add an internal, private state to that
> object/session, it won't be able to call it without modifications to all
> 20 programs, assuming you've created the object/session in each of the
> 20 programs like...
> 
> POE::Session->create(
>       object_states => [ ... ]
> );
> 
> It looks like IKC handles this by exporting subroutines that create the
> sessions, which the main programs then call.  Are there any other
> approaches?

IKC has a bunch of create_ikc_foo() functions that are now deprecated. 
The way you should do it is, as Rocco pointed out, is to create a spawn()
package method.

package MyPoeStuff;
use POE;

sub spawn
{
    my($package, ....)=@_;
    POE::Session->create(....);
}


Which is invoked as 

MyPoeStuff->spawn(...);

-Philip

Reply via email to