SRS::EPP::Session - logic for EPP Session State machine
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;
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:
>hello<, or converted to the back-end format (SRS::Request) and placed in the back-end queue (this is normally immediately dispatched). See "process_queue"
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.
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.
This message is self-fired with a complete packet of data once it has been read.
Enqueues an EPP command for processing and does nothing else.
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.
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.
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.
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.
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.