The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

POEx::ProxySession::Server - Hosts published sessions and routes proxy message

VERSION

version 1.102760

SYNOPSIS

class Flarg { with 'POEx::Role::SessionInstantiation';

    after _start(@args) is Event
    {
        POEx::ProxySession::Server->new
        (
            listen_ip   => '127.0.0.1',
            listen_port => 56789,
            alias       => 'Server',
            options     => { trace => 1, debug => 1 },
        );
    }
}

DESCRIPTION

POEx::ProxySession::Server is a lightweight network server that handles storage and listing of published sessions, and routing of proxied messages between connected clients.

PROTECTED_ATTRIBUTES

sessions

This attribute is used to store the published sessions.

Access these sessions through the following methods:

The stored structure looks like the following:

    Session =>
    {
        name    => isa SessionAlias,
        methods => isa HashRef,
        id      => isa WheelID,
    }

delivered_store

delivered_store holds the wheel ids that are awaiting a response from some other client.

Access to these ids is provided through the following methods:

    handles     => 
    {
        get_delivered        => 'get',
        set_delivered        => 'set',
        delete_delivered     => 'delete',
        count_delivereds     => 'count',
        all_delivered_keys   => 'keys',
        all_delivered_values => 'values',
        has_delivered        => 'exists',
    }

PROTECTED_METHODS

handle_inbound_data

    (ProxyMessage $data, WheelID $id) is Event

Our implementation of handle_inbound_data expects a ProxyMessage as data. Here is where the handling and routing of messages lives. The following types of messages are handled here: publish, rescind, listing, subscribe, deliver, and result.

rescind_session

    (ProxyMessage $data, WheelID $id) is Event

This handles rescinding of a published session. No payload on success.

publish_session

    (ProxyMessage $data, WheelID $id) is Event

This method handles session publication. Payload on success is the session alias

subscribe_session

    (ProxyMessage $data, WheelID $id) is Event

This method handles subscription requests. Payload on success is a hashref:

    Payload =>
    {
        session => isa SessionAlias,
        methods => HashRef,
    }

deliver_message

    (ProxyMessage $data, WheelID $id) is Event

This method does message delivery by doing a lookup of the alias to the real session name, and rewriting the message header to point to that session, then sends it on to that session's connection. Sets a delivered message.

handle_delivered

    (ProxyMessage $data, WheelID $id) is Event

This method handles result messages from delivered messages. All messages that go through the system are expected to return a result message indicating success or failure.

get_listing

    (ProxyMessage $data, WheelID $id) is Event

This method handles listing requests from clients. Should always succeed. Payload is an ArrayRef[SessionAlias].

PRIVATE_METHODS

after _start

    (@args) is Event

The _start method is advised to hardcode the filter to use as a POE::Filter::Reference instance.

AUTHOR

Nicholas Perez <nperez@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Nicholas Perez.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.