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

NAME

VCS::LibCVS::Client::Response - a response in the CVS client protocol

SYNOPSIS

  my @responses = Client::Response->read_from_server($server_conn);
  if (($responses[-1]->isa("VCS::LibCVS::Client::Response::error"))) {
    my $errors;
    foreach my $resp (@responses) { $errors .= $resp->get_errors(); };
    confess "Request failed: $errors";
  } else {
    # remove the "ok" response
    pop @responses;
  }

DESCRIPTION

This is a generic superclass for all of the various responses in the cvsclient protocol. A response includes zero or more pieces of data (LibCVS::Datum), which the server sends. Subclasses of this class should be instantiated, not this class itself.

If a user of the library cannot handle all types of responses from the server it can tailor which responses it can receive in the Client; but only before the connection is established. To do this, use the valid_responses() routine of the VCS::LibCVS::Client class.

The data types for each response are predetermined. Check its documentation to find out what they are. Each response can be queried for its type and the data which it contains, returned as subclasses of LibCVS::Datum. They

CLASS ROUTINES

read_from_ioh()

@responses = Client::Response->read_from_ioh($conn)

Read a list of responses from the server.

return type: a list of Client::Response
argument 1 type: IO::Handle

An IO::Handle from which the list of responses should be read. Typically this will be a link directly from the server.

Reads a list of responses from the server, stopping when it receives an "ok" or "error". This is the typical way to get a response. The number of responses received is unpredictable, as additional responses may be included.

It will block if there is not at least one response.

new()

$response = Client::Response->new($name, $conn)

Read a single response of the given name from the server.

return type: a Client::Response
argument 1 type: scalar

The name of the response as read from the server.

argument 2 type: IO::Handle

A IO::Handle from which the response should be read. Typically this will be a link directly from the server.

Reads a single response from the server and creates an object for it. This routine should only be called in read_from_server above. Users of the libary should call that one, not this one.

The name of the response has already been read from the server. It is similar but not identical to the class name of the response. The only issue is that the '-' character has been replaced by '_'.

INSTANCE ROUTINES

terminal()

$is_terminal = $response->terminal()

return type: boolean

Indicates if this is a terminal response.

A terminal response terminates the list of responses that the server is sending to the user. Only 'ok' and 'error' are terminal responses.

included_data()

@arg_types = $response->included_data()

return type: list of scalar strings

The types of the args that this response expects

Each string is the name of a subpackage of Datum. They are used to construct the response as it is read from the server.

get_errors()

$error_message = $response->get_errors()

return type: scalar string

Returns any error messages

If the response is an error message it will return its string. Otherwise it will return undef.

get_message()

$message = $response->get_message()

return type: scalar string

Returns any regular messages

If the response is a message (M or MB) it will return its string. Otherwise it will return undef.

as_protocol_string()

$response_string = $response->as_protocol_string()

return type: scalar string

Returns the Client::Response as a string as it was received from the server.

data()

$response_data = $response->data()

return type: ref to array containing LibCVS::Datum objects

The order of the returned data is documented for each Response.

SEE ALSO

  VCS::LibCVS::Client
  VCS::LibCVS::Client::Response::Responses
  VCS::LibCVS::Client::Response::FileUpdatingResponses
  VCS::LibCVS::Client::Response::FileUpdateModifyingResponses