The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Net::BEEP::Lite::BaseProfile

SYNOPIS

  $profile = Net::BEEP::Lite::BaseProfile->new();

  my $uri = $profile->uri();

  if ($message->isa('Net::BEEP::Lite::Message') {
    $profile->handle_message($session, $message);
  }

DESCRIPTION

"Net::BEEP::Lite::BaseProfile" is the base class Net::BEEP::Lite profiles should inherit from/implement. It is not intended to be instantiated on its own. This class provides the basic structure of profile.

In general, subclasses only need to override the constructor (for additional initialization parameters, if any) and the various message handler methods (MSG(), RPY(), etc.).

Note that in general BEEP "client" applications generally do not need to create profiles (although they may if they wish). "Server" applications generally do need to create profiles.

Normally profiles are designed to be shared between Sessions. This primarily means that no session or channel base state is stored in the profile object itself. Designers of profiles need not stick to this constraint, however. In this framework, most often each Session is in a different process and thus not actually shared amongst Sessions.

CONSTRUCTOR

new( ARGS )

This constructor currently has no valid arguments.

METHODS

initialize( ARGS )

This method initializes the object. The arguments are named value pairs, although currently none are defined. Users of this class do not call this method, as it is invoked by the constructor. Subclasses, however, should invoke this in their constructors. (i.e., as $self->SUPER::initialize(@_)).

uri([$va])

This returns the profile\'s identifying URI (e.g., http://iana.org/beep/SASL/PLAIN). If passed an optional value, it sets that to the profile's URI.

handle_message($session, $message)

Handle a BEEP message based on its type. This just invokes the profile's various handler functions (MSG(), ERR(), etc.). Returns whatever the handler method returns (generally the original message).

start_channel_request($session, $message, $data)

Handle a start channel request. This is a place for profiles to control what happens when a start channel request for this profile is handled by the management profile. $session is the session the request was received by, $message is the original request, and $data is the data contained within the <start> element, extracted and decoded from base64 (if necessary).

This method must return one of the following responses:

undef

This means that the caller (the management profile) will return a normal <profile> response with no included data and start the channel This is what the base version of this method will return.

('RPY', $content, [$encode])

This means that the caller should return a <profile> response with the included content. If $encode is true, it should base64 encode the content first.

('ERR', $code, $content)

This means that the caller should return this error instead of starting the channel.

'NUL'

This means that the caller should do nothing (don't send a response, don't start the channel), this routine has handled the start channel request.

If not overridden, this routine will return undef, and will stow the data in $session->{start_channel_data}, if there was any.

MSG($session, $message)

Handle MSG type messages. This should be overridden by the subclass. Subclasses should have this method return the original method. This version will simply croak if invoked.

RPY($session, $message)

Handle RPY type messages. This should be overridden by the subclass. Subclasses should have this method return the original method. This version will simply croak if invoked.

ERR($session, $message)

Handle ERR type messages. This should be overridden by the subclass. Subclasses should have this method return the original method. This version will simply croak if invoked.

ANS($session, $message)

Handle ANS type messages. This should be overridden by the subclass. Subclasses should have this method return the original method. This version will simply croak if invoked.

NUL($message)

Handle NUL type messages. This should be overridden by the subclass. Subclasses should have this method return the original method. This version will simply croak if invoked.

SEE ALSO

Net::BEEP::Lite::Message
Net::BEEP::Lite::MgmtProfile