1IO::Async::Protocol::LiUnseeSrtrCeoanmt(r3i)buted Perl DIoOc:u:mAesnytnact:i:oPnrotocol::LineStream(3)
2
3
4

NAME

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

SYNOPSIS

10       Most likely this class will be subclassed to implement a particular
11       network protocol.
12
13          package Net::Async::HelloWorld;
14
15          use strict;
16          use warnings;
17          use base qw( IO::Async::Protocol::LineStream );
18
19          sub on_read_line
20          {
21             my $self = shift;
22             my ( $line ) = @_;
23
24             if( $line =~ m/^HELLO (.*)/ ) {
25                my $name = $1;
26
27                $self->invoke_event( on_hello => $name );
28             }
29          }
30
31          sub send_hello
32          {
33             my $self = shift;
34             my ( $name ) = @_;
35
36             $self->write_line( "HELLO $name" );
37          }
38
39       This small example elides such details as error handling, which a real
40       protocol implementation would be likely to contain.
41

DESCRIPTION

EVENTS

44       The following events are invoked, either using subclass methods or CODE
45       references in parameters:
46
47   on_read_line $line
48       Invoked when a new complete line of input is received.
49

PARAMETERS

51       The following named parameters may be passed to "new" or "configure":
52
53   on_read_line => CODE
54       CODE reference for the "on_read_line" event.
55

METHODS

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

AUTHOR

64       Paul Evans <leonerd@leonerd.org.uk>
65
66
67
68perl v5.36.0                      2023-01-20IO::Async::Protocol::LineStream(3)
Impressum