David Blacka > Net-BEEP-Lite-0.06 > Net::BEEP::Lite::Message

Download:
Net-BEEP-Lite-0.06.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Net::BEEP::Lite::Message

SYNOPSIS ^

  use Net::BEEP::Lite::Message;

  my $message = Net::BEEP::Lite::Message->new
   ( Frame => $frame );

  $message->add_frame($next_frame);

  my $message2 = new Net::BEEP::Lite::Message
   ( Type        => 'MSG',
     Channel     => 3,
     Content     => $content,
     ContentType => 'application/xml' );

  for my $frame ($message2->next_frame($seqno, $max_size)) {
    # ... send the frame
  }

DESCRIPTON ^

This class represents a BEEP message, the basic unit of data transport at the user level. It contains both a reference to the session that it was received on (or will be sent by), and content. It contains methods to construct and deconstruct the message into frames, the actual base unit of transport.

This class is expected to be used in user code by both clients and servers.

CONSTRUCTOR ^

new( ARGS )

This is the main constructor. It takes a named parameter list as its argument. The following parameters are recognized:

Session

A reference to the session that the message was received by or will be sent by.

Type

The message type (e.g., "MSG", "RPY", "ERR", etc.)

Msgno

The message number. This is generally fetched from the session, or, for replies, from the message being replied to. This should only be set for replies. 'MSG's should be set by the session on sending it.

Channel

The channel number.

Payload

The message payload (including the MIME header(s)). Either this or "Content" and "ContentType" MUST be supplied.

Content

The message content (not including the MIME headers).

ContentType

The message content type. This will be added as a MIME header when forming the payload. If not supplied, the default content type is 'application/octet-stream'.

ContentEncoding

The content encoding. This will be added as a MIME header when forming the payload, if supplied.

Frame

A frame to form the basis (or entire) message. Generally, this is supplied on its own.

Debug

Emit debug messages.

METHODS ^

type([$val])

Returns the type of the message (e.g., "MSG", "RPY", etc.). Updates the type to $val if provided.

msgno([$val])

Returns (or sets) the message number of the message.

size()

Returns the size of the payload of the message.

channel_number([$va])

Returns or sets the channel number of the message.

payload()

Returns the payload of the message, forming it from the content, content type, and content encoding, if necessary.

content_type()

Returns the content type of the message (either set or parsed from the payload).

content_encoding()

Returns the content encoding of the message (if one where set or detected from the payload).

content()

Returns the content of the message (the payload minus MIME headers). It calculates the content from the payload, if necessary.

_content_payload_transfer()

This will force the translation between content and payload. Currently this can only be done once, but then again, this class doesn't support changing either of them through the API. If you do so, be sure to set the other to undef so that this routine will work.

_decode_mime()

Parse the payload into content, content type, and content encoding. This is normally called automatically.

_encode_mime()

Calculate the payload from the set content, content type, and content encoding. This is normally called automatically.

add_frame($frame)

Add a frame to an existing message. This is used to assemble a message from multiple frames. For now, this method doesn't really check that the additional frames really belong to the message.

has_more_frames()

Return true if there are more frames to be generated from this message.

next_frame($seqno, $max_size)

Returns the "next" frame in the message, based on given maximum size. This method will split the message into multiple frames if the maximum size forces it to. This will return undef when the entire message has been rendered into frames. See the reset_frames() method if you wish to convert the same message into frames multiple times.

reset_frames()

This will reset the counter used by next_frame(). Use this if you want to start calculating frames from the beginning more than once.

SEE ALSO ^

Net::BEEP::Lite::Session
Net::BEEP::Lite::Frame
syntax highlighting: