File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
src/ModelContextProtocol.AspNetCore Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,15 @@ internal sealed class HttpMcpSession<TTransport>(
25
25
public bool IsActive => ! SessionClosed . IsCancellationRequested && _referenceCount > 0 ;
26
26
public long LastActivityTicks { get ; private set ; } = timeProvider . GetTimestamp ( ) ;
27
27
28
+ private TimeProvider TimeProvider => timeProvider ;
29
+
28
30
public IMcpServer ? Server { get ; set ; }
29
31
public Task ? ServerRunTask { get ; set ; }
30
32
31
33
public IDisposable AcquireReference ( )
32
34
{
33
35
Interlocked . Increment ( ref _referenceCount ) ;
34
- return new UnreferenceDisposable ( this , timeProvider ) ;
36
+ return new UnreferenceDisposable ( this ) ;
35
37
}
36
38
37
39
public bool TryStartGetRequest ( ) => Interlocked . Exchange ( ref _getRequestStarted , 1 ) == 0 ;
@@ -70,13 +72,13 @@ public async ValueTask DisposeAsync()
70
72
public bool HasSameUserId ( ClaimsPrincipal user )
71
73
=> UserIdClaim == StreamableHttpHandler . GetUserIdClaim ( user ) ;
72
74
73
- private sealed class UnreferenceDisposable ( HttpMcpSession < TTransport > session , TimeProvider timeProvider ) : IDisposable
75
+ private sealed class UnreferenceDisposable ( HttpMcpSession < TTransport > session ) : IDisposable
74
76
{
75
77
public void Dispose ( )
76
78
{
77
79
if ( Interlocked . Decrement ( ref session . _referenceCount ) == 0 )
78
80
{
79
- session . LastActivityTicks = timeProvider . GetTimestamp ( ) ;
81
+ session . LastActivityTicks = session . TimeProvider . GetTimestamp ( ) ;
80
82
}
81
83
}
82
84
}
You can’t perform that action at this time.
0 commit comments