| 1 | # You may distribute under the terms of either the GNU General Public License | ||||||||||
| 2 | # or the Artistic License (the same terms as Perl itself) | ||||||||||
| 3 | # | ||||||||||
| 4 | # (C) Paul Evans, 2010-2024 -- leonerd@leonerd.org.uk | ||||||||||
| 5 | |||||||||||
| 6 | 9 | ▶ | use v5.26; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 9 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 9 | ▶ | use Object::Pad 0.800; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | package Tangence::Server::Context 0.33; | ||||||||||
| 11 | class Tangence::Server::Context; | ||||||||||
| 12 | |||||||||||
| 13 | 9 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 14 | |||||||||||
| 15 | 9 | ▶ | use Tangence::Constants; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 16 | |||||||||||
| 17 | =head1 NAME | ||||||||||
| 18 | |||||||||||
| 19 | C<Tangence::Server::Context> - server connection class for C<Tangence> | ||||||||||
| 20 | |||||||||||
| 21 | =head1 DESCRIPTION | ||||||||||
| 22 | |||||||||||
| 23 | This module is a component of L<Tangence::Server>. It is not intended for | ||||||||||
| 24 | end-user use directly. | ||||||||||
| 25 | |||||||||||
| 26 | =cut | ||||||||||
| 27 | |||||||||||
| 28 | 23 | ▶ | field $stream :param :reader; | ||||||||
|
Subroutine
stream: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 29 | 9 | field $token :param; | |||||||||
| 30 | |||||||||||
| 31 | 95 | ▶ | sub BUILDARGS ( $class, $stream, $token ) | ||||||||
|
Subroutine
BUILDARGS: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 32 | { | ||||||||||
| 33 | 95 | return ( stream => $stream, token => $token ); | |||||||||
| 34 | } | ||||||||||
| 35 | |||||||||||
| 36 | 9 | field $responded; | |||||||||
| 37 | |||||||||||
| 38 | # TODO: Object::Pad probably should do this bit | ||||||||||
| 39 | method DESTROY | ||||||||||
| 40 | 95 | ▶ | { | ||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=7.6
| |||||||||||
| 41 | 95 | ▶ | $responded or croak "$self never responded"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 42 | 9 | } | |||||||||
| 43 | |||||||||||
| 44 | 95 | ▶ | method respond ( $message ) | ||||||||
|
Subroutine
respond: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||
| 45 | { | ||||||||||
| 46 | 95 | ▶ | $responded and croak "$self has responded once already"; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 47 | |||||||||||
| 48 | 95 | $stream->respond( $token, $message ); | |||||||||
| 49 | |||||||||||
| 50 | 95 | $responded = 1; | |||||||||
| 51 | |||||||||||
| 52 | 95 | return; | |||||||||
| 53 | 9 | } | |||||||||
| 54 | |||||||||||
| 55 | 6 | ▶ | method responderr ( $msg ) | ||||||||
|
Subroutine
responderr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 56 | { | ||||||||||
| 57 | 6 | chomp $msg; # In case of simple ->responderr( $@ ); | |||||||||
| 58 | |||||||||||
| 59 | 6 | $self->respond( Tangence::Message->new( $stream, MSG_ERROR ) | |||||||||
| 60 | ->pack_str( $msg ) | ||||||||||
| 61 | ); | ||||||||||
| 62 | 9 | } | |||||||||
| 63 | |||||||||||
| 64 | =head1 AUTHOR | ||||||||||
| 65 | |||||||||||
| 66 | Paul Evans <leonerd@leonerd.org.uk> | ||||||||||
| 67 | |||||||||||
| 68 | =cut | ||||||||||
| 69 | |||||||||||
| 70 | 9 | 0x55AA; | |||||||||