Inca::Net::Protocol::Statement - Convenience object for creating Inca protocol statements
use Inca::Net::Protocol::Statement; my $statement = new Inca::Net::Protocol::Statement(); $statement->setCmd( "PING" ); $statement->setData( "me" ); print $statement->toString();
This class assists in sending/receiving and parsing the Inca protocol. The Inca protocol is a sequence of statements where a statement is the most basic part of the Inca Protocol. It has the following patterm: CMD SP DATA CRLF.
A text string indicating an action or description of the data that follows.
A space.
The crux of the message containing any stream of characters except CRLF.
A carriage return followed by a line feed indicating the end of the statement.
Class constructor which returns a new Inca::Net::Protocol::Statement object. The constructor may be called with any of the following attributes.
Options:
- cmd
Set the CMD string of the statement.
- data
Set the DATA of the statement.
- stmt
Parse an existing Inca statement.
Returns the CMD string of the statement.
Returns:
A text string indicating an action or description of the data that follows.
Returns the DATA part of the statement.
Returns:
The crux of the message containing any stream of characters except CRLF.
Creates a new ERROR message with the given error message. An error message will serve to close the connection between client and server.
Arguments:
- error
A string containing an error message to report to the other side of the connection.
Returns:
Returns a new statement representing: ERROR SP Error Message CRLF
Creates a new OK message with the supplied $data. If $data is not specified, 100 is used.
Options:
- data
An string representing information to send with the OK statement [default: 100]
Returns:
Returns a new statement representing: OK SP DATA CRLF
Returns a new Start message with the current Inca protocol version.
Returns:
Returns a new statement object representing: START SP Version CRLF
Returns a string containing the Inca statement. Equivalent to toString()
Returns:
A complete string representing a Statement in the Inca protocol.
Set the CMD string of the statement.
Arguments:
- cmd
A text string indicating an action or description of the data that follows.
Set the DATA string of the statement.
Arguments:
- data
The crux of the message containing any stream of characters except CRLF.
Parse an existing Inca statement into the existing object.
Arguments:
- stmt
A string containing the Inca statement in the format: CMD SP DATA CRLF.
Returns completed statement as a string.
Returns:
A complete string representing a Statement in the Inca protocol.
Shava Smallen <ssmallen@sdsc.edu>