Andrew Chilton > SRS-EPP-Proxy-0.21 > SRS::EPP::Session

Download:
SRS-EPP-Proxy-0.21.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Source   Latest Release: SRS-EPP-Proxy-0.22

NAME ^

SRS::EPP::Session - logic for EPP Session State machine

SYNOPSIS ^

 my $session = SRS::EPP::Session->new( io => $socket );

 #--- session events:

 $session->connected;
 $session->input_event;
 $session->input_packet($data);
 $session->queue_command($command);
 $session->process_queue($count);
 $session->be_response($srs_rs);
 $session->send_pending_replies();
 $session->send_reply($response);
 $session->output_event;

 #--- information messages:

 # print RFC3730 state eg 'Waiting for Client',
 # 'Prepare Greeting' (see Page 4 of RFC3730)
 print $session->state;

 # return the credential used for login
 print $session->user;

DESCRIPTION ^

The SRS::EPP::Session class manages the flow of individual connections. It implements the "EPP Server State Machine" from RFC3730, as well as the exchange encapsulation described in RFC3734 "EPP TCP Transport".

This class is designed to be called from within an event-based framework; this is fairly essential in the context of a server given the potential to deadlock if the client does not clear its responses in a timely fashion.

Input commands go through several stages:

METHODS ^

connected()

This event signals to the Session that the client is now connected. It signals that it is time to issue a >greeting< response, just as if a >hello< message had been received.

input_event()

This event is intended to be invoked whenever there is data ready to read on the input socket. It returns false if not enough data could be read to get a complete subpacket.

input_packet($data)

This message is self-fired with a complete packet of data once it has been read.

queue_command($command)

Enqueues an EPP command for processing and does nothing else.

process_queue($count)

Processes the back-end queue, up to $count at a time. At the end of this, if there are no outstanding back-end transactions, any produced SRS::Request objects are wrapped into an SRS::Transaction object and dispatched to the back-end.

Returns the number of commands remaining to process.

be_response($srs_rs)

This is fired when a back-end response is received. It is responsible for matching responses with commands in the command queue and converting to SRS::EPP::Response objects.

send_pending_replies()

This is called by process_queue() or be_response(), and checks each command for a corresponding SRS::EPP::Response object, dequeues and starts to send them back.

send_reply($response)

This is called by send_pending_replies(), and converts a SRS::EPP::Response object to network form, then starts to send it. Returns the total number of octets which are currently outstanding; if this is non-zero, the caller is expected to watch the output socket for writability and call output_event() once it is writable.

output_event()

This event is intended to be called when the return socket is newly writable; it writes everything it can to the output socket and returns the number of bytes written.

SEE ALSO ^

SRS::EPP::Command, SRS::EPP::Response

syntax highlighting: