=for comment POD_DERIVED_INDEX_GENERATED
The following documentation is automatically generated.  Please do not edit
this file, but rather the original, inline with Protocol::SPDY::Base
at lib/Protocol/SPDY/Base.pm
(on the system that originally ran this).
If you do edit this file, and don't want your changes to be removed, make
sure you change the first line.

=cut

=head1 NAME

Protocol::SPDY::Base - abstract support for the SPDY protocol

=head1 VERSION

version 0.999_001

=head1 DESCRIPTION

Provides the base class for client, server and generic (proxy/analysis)
SPDY handling.

=head1 METHODS

=head2 new

Instantiates a new SPDY-handling object. Applies any attributes
passed as named parameters.

=head2 sender_zlib

The compression instance used for sending data.

=head2 receiver_zlib

Compression instance used for receiving (decompressing) data.

=head2 request_close

Issue a close request by sending a GOAWAY message.

=head2 check_version

Called before we do anything with a control frame.

Returns true if it's supported, false if not.

=head2 next_stream_id

Generate the next stream ID for this connection.

Returns the next available stream ID, or 0 if we're out of available streams

=head2 queue_frame

Requests sending the given C< $frame > at the earliest opportunity.

=head2 on_read

This is the method that an external transport would call when it has
some data received from the other side of the SPDY connection. It
expects to be called with a scalar containing bytes which can be
decoded as SPDY frames; any SSL/TLS decoding should happen before
passing data to this method.

Will call L</dispatch_frame> for any valid frames that can be
extracted from the stream.

=head2 prioritise_incoming_frames

Given a list of L<Protocol::SPDY::Frame> instances, returns them
reordered so that higher-priority items such as PING are handled
first.

Does not yet support stream priority.

=head2 dispatch_frame

Dispatches the given frame to appropriate handlers - this will
be the matching L<Protocol::SPDY::Stream> if one exists, or
internal connection state handling for GOAWAY/SETTINGS frames.

=head2 incoming_stream

Called when a new SYN_STREAM frame is received.

=head2 related_stream

Returns the L<Protocol::SPDY::Stream> matching the stream_id
for this frame (if it has one).

Will return undef if we have no stream yet or this frame
does not have a stream_id.

=head2 apply_settings

Applies the given settings to our internal state.

B< Note >: Not yet implemented

=head2 extract_frame

Given a scalar reference to a byte buffer, this will extract the first frame if possible
and return the bytes if it succeeded, undef if not. No frame validation is performed: the
bytes are extracted based on the length information only.

=head2 parse_frame

Parse a frame extracted by L</extract_frame>. Returns an appropriate subclass of L<Protocol::SPDY::Frame>
if this succeeded, dies if it fails.

=head2 goaway

Requests termination of the connection.

=head2 ping

Sends a ping request. We should get a PING packet back as a high-priority reply.

=head2 settings

Send settings to the remote.

=head2 credential

Sends credential information to the remote.

=head2 version

Returns the version supported by this instance. Currently, this is
always 3.

=head2 last_stream_id

The ID for the last stream we created.

=head2 write

Calls the external code which is expected to handle writes.

=head2 create_stream

Instantiate a new stream, returning the L<Protocol::SPDY::Stream> instance.

=head2 pending_send

Returns a count of the frames that are waiting to be sent.

=head2 has_stream

Returns true if we have a stream matching the ID on the
provided L<Protocol::SPDY::Stream> instance.

=head2 stream_by_id

Returns the L<Protocol::SPDY::Stream> matching the given ID.

=head1 INHERITED METHODS

=over 4

=item L<Mixin::Event::Dispatch>

L<add_handler_for_event|Mixin::Event::Dispatch/add_handler_for_event>, L<clear_event_handlers|Mixin::Event::Dispatch/clear_event_handlers>, L<event_handlers|Mixin::Event::Dispatch/event_handlers>, L<invoke_event|Mixin::Event::Dispatch/invoke_event>, L<subscribe_to_event|Mixin::Event::Dispatch/subscribe_to_event>, L<unsubscribe_from_event|Mixin::Event::Dispatch/unsubscribe_from_event>

=back

=head1 AUTHOR

Tom Molesworth <cpan@entitymodel.com>

=head1 LICENSE

Copyright Tom Molesworth 2011-2013. Licensed under the same terms as Perl itself.
