NAME
Protocol::BitTorrent::Message - base class for BitTorrent messages
VERSION
version 0.004
SYNOPSIS
use Protocol::BitTorrent::Message;
$sock->read(my $buf, 4096);
while(my $msg = Protocol::BitTorrent::Message->new_from_buffer(\$buf)) {
$self->handle_message($msg);
}
DESCRIPTION
See Protocol::BitTorrent and Protocol::BitTorrent::Metainfo for usage information.
METHODS
new
Base method for instantiation, returns a blessed object.
new_from_buffer
Returns an instance of a Protocol::BitTorrent::Message subclass, or undef if insufficient data has been provided in the buffer.
Takes a single scalar ref as parameter - this should be a reference to the scalar buffer containing data to be parsed. Removes packet data from this buffer if parsing was successful.
class_name_by_type
Returns the class name for the given type (as taken from a BitTorrent network packet).
as_string
Returns a stringified version of this message.
type
Returns the type for this message - stub method for base class, should be overridden in subclasses.
AUTHOR
Tom Molesworth <cpan@entitymodel.com>
LICENSE
Copyright Tom Molesworth 2011. Licensed under the same terms as Perl itself.