<<

NAME

Inca::Net::Protocol::Statement - Convenience object for creating Inca protocol statements

SYNOPSIS

  use Inca::Net::Protocol::Statement;
  my $statement = new Inca::Net::Protocol::Statement();
  $statement->setCmd( "PING" );
  $statement->setData( "me" );
  print $statement->toString();

DESCRIPTION

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.

CMD

A text string indicating an action or description of the data that follows.

SP

A space.

DATA

The crux of the message containing any stream of characters except CRLF.

CRLF

A carriage return followed by a line feed indicating the end of the statement.

CLASS METHODS

new( %Options )

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.

getCmd( )

Returns the CMD string of the statement.

Returns:

A text string indicating an action or description of the data that follows.

getData( )

Returns the DATA part of the statement.

Returns:

The crux of the message containing any stream of characters except CRLF.

getErrorStatement( $error )

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

getOkStatement( data => $data )

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

getStartStatement( )

Returns a new Start message with the current Inca protocol version.

Returns:

Returns a new statement object representing: START SP Version CRLF

getStatement( )

Returns a string containing the Inca statement. Equivalent to toString()

Returns:

A complete string representing a Statement in the Inca protocol.

setCmd( $cmd )

Set the CMD string of the statement.

Arguments:

cmd

A text string indicating an action or description of the data that follows.

setData( $cmd )

Set the DATA string of the statement.

Arguments:

data

The crux of the message containing any stream of characters except CRLF.

setStatement( $stmt )

Parse an existing Inca statement into the existing object.

Arguments:

stmt

A string containing the Inca statement in the format: CMD SP DATA CRLF.

toString( )

Returns completed statement as a string.

Returns:

A complete string representing a Statement in the Inca protocol.

AUTHOR

Shava Smallen <ssmallen@sdsc.edu>

<<