.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "IO::Async::Protocol::LineStream 3pm" .TH IO::Async::Protocol::LineStream 3pm 2024-02-04 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME "IO::Async::Protocol::LineStream" \- stream\-based protocols using lines of text .SH SYNOPSIS .IX Header "SYNOPSIS" Most likely this class will be subclassed to implement a particular network protocol. .PP .Vb 1 \& 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" ); \& } .Ve .PP This small example elides such details as error handling, which a real protocol implementation would be likely to contain. .SH DESCRIPTION .IX Header "DESCRIPTION" .SH EVENTS .IX Header "EVENTS" The following events are invoked, either using subclass methods or CODE references in parameters: .ie n .SS "on_read_line $line" .el .SS "on_read_line \f(CW$line\fP" .IX Subsection "on_read_line $line" Invoked when a new complete line of input is received. .SH PARAMETERS .IX Header "PARAMETERS" The following named parameters may be passed to \f(CW\*(C`new\*(C'\fR or \f(CW\*(C`configure\*(C'\fR: .SS "on_read_line => CODE" .IX Subsection "on_read_line => CODE" CODE reference for the \f(CW\*(C`on_read_line\*(C'\fR event. .SH METHODS .IX Header "METHODS" .SS write_line .IX Subsection "write_line" .Vb 1 \& $lineprotocol\->write_line( $text ); .Ve .PP Writes a line of text to the transport stream. The text will have the end-of-line marker appended to it; \f(CW$text\fR should not end with it. .SH AUTHOR .IX Header "AUTHOR" Paul Evans