Vincent Pit

NAME

Bit::MorseSignals::Emitter - Base class for Bit::MorseSignals emitters.

VERSION

Version 0.08

SYNOPSIS

    use Bit::MorseSignals::Emitter;

    my $deuce = Bit::MorseSignals::Emitter->new;
    $deuce->post("hlagh") for 1 .. 3;
    while (defined(my $bit = $deuce->pop)) {
     sends_by_some_mean_lets_say_signals($bit);
    }

DESCRIPTION

Base class for Bit::MorseSignals emitters. Please refer to this module for more general information about the protocol.

The emitter object enqueues messages and prepares them one by one into Bit::MorseSignals packets. It gives then back the bits of the packet in the order they should be sent.

METHODS

new

Bit::MorseSignals::Emitter object constructor. Currently does not take any optional argument.

post $msg, < type => $type >

Adds $msg to the message queue and, if no other message is currently processed, dequeue the oldest item and prepare it. The type is automatically chosen, but you may want to try to force it with the type option : $type is then one of the BM_DATA_* constants listed in "CONSTANTS" in Bit::MorseSignals

pop

If a message is being processed, pops the next bit in the packet. When the message is over, the next in the queue is immediatly prepared and the first bit of the new packet is given back. If the queue is empty, undef is returned. You may want to use this method with the idiom :

    while (defined(my $bit = $deuce->pop)) {
     ...
    }

len

The length of the currently posted message.

pos

The number of bits that have already been sent for the current message.

reset

Cancels the current transfer, but does not empty the queue.

flush

Flushes the queue, but does not cancel the current transfer.

busy

True when the emitter is busy, i.e. when a packet is being chunked.

queued

Returns the number of queued items.

EXPORT

An object module shouldn't export any function, and so does this one.

DEPENDENCIES

Carp (standard since perl 5), Encode (since perl 5.007003), Storable (idem).

SEE ALSO

Bit::MorseSignals, Bit::MorseSignals::Receiver.

AUTHOR

Vincent Pit, <perl at profvince.com>, http://www.profvince.com.

You can contact me by mail or on irc.perl.org (vincent).

BUGS

Please report any bugs or feature requests to bug-bit-morsesignals-emitter at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Bit-MorseSignals. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

SUPPORT

You can find documentation for this module with the perldoc command.

    perldoc Bit::MorseSignals::Emitter

Tests code coverage report is available at http://www.profvince.com/perl/cover/Bit-MorseSignals.

COPYRIGHT & LICENSE

Copyright 2008 Vincent Pit, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.