NAME

Net::BitTorrent::Protocol::Simulation - Protocol handler for tests and swarm simulations

SYNOPSIS

use Net::BitTorrent::Protocol::Simulation;

my $proto = Net::BitTorrent::Protocol::Simulation->new(
    peer_id  => $my_id,
    infohash => $ih
);
$proto->peer($peer_object);

DESCRIPTION

Net::BitTorrent::Protocol::Simulation is a subclass of Net::BitTorrent::Protocol::BEP11 designed for use in tests and simulations.

It allows a Net::BitTorrent::Peer object to be associated directly with the protocol handler, bypassing the usual event-driven network transport for easier manipulation of peer state during simulated swarm behavior.

METHODS

peer( )

Returns or sets the associated Peer object.

my $p = $proto->peer();
$proto->peer( $p );

Expected parameters:

$peer - optional

The Peer object to associate with this handler.

_handle_message( $id, $payload )

Internal method that overrides the default message handling to forward messages to the associated peer object before passing them up the inheritance chain.

SEE ALSO

Net::BitTorrent::Protocol::BEP11, Net::BitTorrent::Peer

AUTHOR

Sanko Robinson <sanko@cpan.org>

COPYRIGHT

Copyright (C) 2008-2026 by Sanko Robinson.

This library is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0.