File: ServerProtocol.pm

package info (click to toggle)
libnet-async-tangence-perl 0.16-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 220 kB
  • sloc: perl: 1,593; makefile: 2
file content (78 lines) | stat: -r--r--r-- 1,467 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#  You may distribute under the terms of either the GNU General Public License
#  or the Artistic License (the same terms as Perl itself)
#
#  (C) Paul Evans, 2010-2020 -- leonerd@leonerd.org.uk

package Net::Async::Tangence::ServerProtocol 0.16;

use v5.14;
use warnings;

use base qw( Net::Async::Tangence::Protocol Tangence::Server );
use mro 'c3';

use Carp;

=head1 NAME

C<Net::Async::Tangence::ServerProtocol> - C<Net::Async::Tangence::Protocol>
subclass for servers

=head1 DESCRIPTION

This subclass of L<Net::Async::Tangence::Protocol> provides additional logic
required by the server side of a connection. It is not intended to be directly
used by server implementations.

=cut

sub _init
{
   my $self = shift;
   my ( $params ) = @_;

   $self->registry( delete $params->{registry} );

   $params->{on_closed} ||= undef;

   $self->SUPER::_init( $params );
}

sub configure
{
   my $self = shift;
   my %params = @_;

   if( exists $params{on_closed} ) {
      my $on_closed = $params{on_closed};
      $params{on_closed} = sub {
         my $self = shift;

         $on_closed->( $self ) if $on_closed;
      };
   }

   $self->SUPER::configure( %params );
}

sub rootobj
{
   my $self = shift;
   my ( $identity ) = @_;

   return $self->parent->conn_rootobj( $self, $identity );
}

sub permit_registry
{
   my $self = shift;
   return $self->parent->conn_permits_registry( $self );
}

=head1 AUTHOR

Paul Evans <leonerd@leonerd.org.uk>

=cut

0x55AA;