Add 3-arg RequestContext constructor and obsolete 2-arg to eliminate null-forgiving operator usage (#1462)
This commit is contained in:
parent
afc40d1e2e
commit
7dcdbafe9d
1 changed files with 190 additions and 219 deletions
|
|
@ -212,7 +212,7 @@ builder.Services.AddMcpServer()
|
|||
.WithResources<MyResources>()
|
||||
.WithSubscribeToResourcesHandler(async (ctx, ct) =>
|
||||
{
|
||||
if (ctx.Params?.Uri is { } uri)
|
||||
if (ctx.Params.Uri is { } uri)
|
||||
{
|
||||
// Track the subscription (e.g., in a concurrent dictionary)
|
||||
subscriptions[ctx.Server.SessionId].TryAdd(uri, 0);
|
||||
|
|
@ -221,7 +221,7 @@ builder.Services.AddMcpServer()
|
|||
})
|
||||
.WithUnsubscribeFromResourcesHandler(async (ctx, ct) =>
|
||||
{
|
||||
if (ctx.Params?.Uri is { } uri)
|
||||
if (ctx.Params.Uri is { } uri)
|
||||
{
|
||||
subscriptions[ctx.Server.SessionId].TryRemove(uri, out _);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue