Hi,

I'm writing a POE server, and during the last week, I was not comfortable with some of the design.

In POE, the binding between sessions is too strong. Most of the time, you create a session and you specify which functions will handle the event or which other session will receive those events.

What I needed was a looser connection between sessions: a session that generates the event notifies a shared message bus, and all the interested sessions listen to that bus.

This allows me to add more sessions in the future, to add further funcionalities, without having to recode older sessions (unless I need a new event that is).

I coded some sample stuff to use it. It goes more or less like this:

my $bus1 = MessageBus->new;
my $bus2 = MessageBus->new;

my $producer = Session->new;
$producer->attach( $bus1 );
$producer->attach( $bus2 );

my $consumer1 = Session->new;
my $consumer2 = Session->new;
my $consumer3 = Session->new;

$consumer1->attach( $bus1 );
$consumer2->attach( $bus1 );
$consumer3->attach( $bus2 );

Events can now flow on each bus. Only sessions that attach to a specific bus can send or receive messages on this bus.

Before I code even more, does anybody done this before?

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

Attachment: smime.p7s
Description: S/MIME cryptographic signature



Reply via email to