MCP/Server/Session.pm

filter: Statementstmt 88.8% 8 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod 100% 1 / 1 totaltotal 84.6% 11 / 13 CC 1 SCAR 0.4
CC
1
Cov
89%
__ANON__
1.1
BEGIN
1.0
touch
1.0
CRAP 1.0
« MCP/Primitive.pm ↑ Summary
1 package MCP::Server::Session;
2 4 ▶use Mojo::Base -base, -signatures;
Subroutine BEGIN: called CC=1 SCAR=0.0
3  
4 4 has [qw(id stream)];
5 0 ▶has last_used => sub {time};
Subroutine __ANON__: not called CC=1 SCAR=1.2
6  
7 ▶sub touch ($self) {
Subroutine touch: called CC=1 SCAR=0.0
Pod documented
8 24 $self->last_used(time);
9 24 return $self;
10 }
11  
12 4 1;
13  
14 =encoding utf8
15  
16 =head1 NAME
17  
18 MCP::Server::Session - Session container
19  
20 =head1 SYNOPSIS
21  
22 use MCP::Server::Session;
23  
24 my $session = MCP::Server::Session->new(id => '12345');
25 $session->touch;
26  
27 =head1 DESCRIPTION
28  
29 L<MCP::Server::Session> is a container for per-session state.
30  
31 =head1 ATTRIBUTES
32  
33 L<MCP::Server::Session> implements the following attributes.
34  
35 =head2 id
36  
37 my $id = $session->id;
38 $session = $session->id('12345');
39  
40 The session identifier.
41  
42 =head2 last_used
43  
44 my $time = $session->last_used;
45 $session = $session->last_used(time);
46  
47 Epoch seconds of the last activity on this session, defaults to the time the session was created. Updated by
48 L</"touch">.
49  
50 =head2 stream
51  
52 my $stream = $session->stream;
53 $session = $session->stream(Mojolicious::Controller->new);
54  
55 The L<Mojolicious::Controller> currently serving the server-to-client SSE stream for this session, or C<undef> if
56 no stream is open.
57  
58 =head1 METHODS
59  
60 L<MCP::Server::Session> inherits all methods from L<Mojo::Base> and implements the following new ones.
61  
62 =head2 touch
63  
64 $session = $session->touch;
65  
66 Set L</"last_used"> to the current time.
67  
68 =head1 SEE ALSO
69  
70 L<MCP>, L<https://mojolicious.org>, L<https://modelcontextprotocol.io>.
71  
72 =cut
« MCP/Primitive.pm ↑ Summary