GNU.WIKI: The GNU/Linux Knowledge Base

  [HOME] [PHP Manual] [HowTo] [ABS] [MAN1] [MAN2] [MAN3] [MAN4] [MAN5] [MAN6] [MAN7] [MAN8] [MAN9]

  [0-9] [Aa] [Bb] [Cc] [Dd] [Ee] [Ff] [Gg] [Hh] [Ii] [Jj] [Kk] [Ll] [Mm] [Nn] [Oo] [Pp] [Qq] [Rr] [Ss] [Tt] [Uu] [Vv] [Ww] [Xx] [Yy] [Zz]


       "IO::Async::Protocol::LineStream" - stream-based protocols using lines
       of text


       Most likely this class will be subclassed to implement a particular
       network protocol.

        package Net::Async::HelloWorld;

        use strict;
        use warnings;
        use base qw( IO::Async::Protocol::LineStream );

        sub on_read_line
           my $self = shift;
           my ( $line ) = @_;

           if( $line =~ m/^HELLO (.*)/ ) {
              my $name = $1;

              $self->invoke_event( on_hello => $name );

        sub send_hello
           my $self = shift;
           my ( $name ) = @_;

           $self->write_line( "HELLO $name" );

       This small example elides such details as error handling, which a real
       protocol implementation would be likely to contain.



       The following events are invoked, either using subclass methods or CODE
       references in parameters:

   on_read_line $line
       Invoked when a new complete line of input is received.


       The following named parameters may be passed to "new" or "configure":

       on_read_line => CODE
               CODE reference for the "on_read_line" event.


   $lineprotocol->write_line( $text )
       Writes a line of text to the transport stream. The text will have the
       end-of-line marker appended to it; $text should not end with it.


       Paul Evans <>

perl v5.20.0                      2014-08-IO::Async::Protocol::LineStream(3pm)

  All copyrights belong to their respective owners. Other content (c) 2014-2018, GNU.WIKI. Please report site errors to
Page load time: 0.195 seconds. Last modified: November 04 2018 12:49:43.