NAME

Net::BeepLite::ClientSession

SYNOPSIS

my $c_session = Net::BeepLite::ClientSession->new(Socket => $sock);

my $channel_num = $c_session->start_channel('http://some/profile/url',
                                            (ServerName => "some.host.org"));

my $resp = $c_session->send_and_recv_message(ContentType => "text/plain",
                                             Content => "hello!");

$c_session->close_channel($channel_num);
$c_session->close_channel(0); # close session.

DESCRIPTION

This is the session subclass that handles the pure "client" case. This models the case of a process sending individual messages and dealing with individual replies on its own. In general, "clients" do not advertise any profiles, so it is impossible for the peer to open any new channels.

CONSTRUCTOR

new( ARGS )

This is the main constructor for this class. It takes a named parameter list. It accepts all parameters defined by the initialize method (see below) and its superclass constructor (see Net::BeepLite::Session).

This constructor will attempt to establish a valid BEEP session (i.e., it will send and process the greeting message.) if it is passed an actual socket in the constructor. If not (or if NoGreeting is set to true), it is up to the calling code to send the greeting.

METHODS

initialize( ARGS )

This will initialize the object. It is generally called from the constructor. At the moment it does not define any new named parameters in addition to those supported by the superclass.

start_channel( ARGS )

Sends a start channel request to the peer. The named arguments are:

URI

The URI of the BEEP profile to use this channel. This is mandatory.

ServerName

The "server name" to present to the server. Essentially this is the name the client thinks the server is. It is optional.

StartData

Data to piggyback with the start channel request. This is optional.

Encoding

Set this to true of the StartData value is base64 encoded.

This returns the channel number started, or dies on failure.

See the start_channel_message method in Net::BeepLite::MgmtProfile.

close_channel($channel_number, [$code, $content, $lang])

Sends a "close" message for the given channel. See the close_channel_message in Net::BeepLite:MgmtProfile for more information.

new_message( ARGS )

This is a convenience method for creating new messages. It accepts the following named parameters:

Type

One of "MSG", "RPY", etc. Defaults to "MSG".

Channel

The channel number to use. This defaults to the "current channel", which is the last successfully opened channel.

Content

The message content.

Content-Type (or ContentType, or contenttype)

The MIME content type. This defaults to 'application/octet-stream'.

send_and_recv_message( ARGS )

This is a convenience method for send and message and receiving the response to it all in one step. This takes the same named parameters as the new_message method.

Note: currently this will have trouble with multiple channels.

selected_profile([$uri])

Returns the profile selected from the last successful start channel.

current_channel([$channel_number])

Returns the current channel number.

SEE ALSO

Net::BeepLite::Session