3using System.Threading.Tasks;
16 private readonly HashSet<string> subscriptions =
new HashSet<string>();
18 private readonly
bool hasSnifferSet;
20 private string userName =
"Not Authenticated";
21 private bool isAuthenticated =
false;
86 [Obsolete(
"Use DisposeAsync instead.")]
97 if (!(this.unauthenticatedSniffer is
null))
100 this.unauthenticatedSniffer =
null;
103 lock (this.subscriptions)
105 this.subscriptions.Clear();
114 internal async Task SetUserName(
string UserName)
118 if (!this.isAuthenticated)
120 this.isAuthenticated =
true;
122 if (this.hasSnifferSet)
125 if (!(this.unauthenticatedSniffer is
null))
128 this.unauthenticatedSniffer =
null;
137 internal void ReceiveText(
string Text)
139 if (this.hasSnifferSet)
141 if (this.isAuthenticated)
142 this.snifferSet!.ReceiveText(this.userName, Text);
154 if (this.hasSnifferSet)
156 if (this.isAuthenticated)
157 this.snifferSet!.TransmitText(this.userName, Text);
167 internal void Information(
string Text)
169 if (this.hasSnifferSet)
171 if (this.isAuthenticated)
172 this.snifferSet!.Information(this.userName, Text);
182 internal void Warning(
string Text)
184 if (this.hasSnifferSet)
186 if (this.isAuthenticated)
187 this.snifferSet!.Warning(this.userName, Text);
189 this.unauthenticatedSniffer?.
Warning(Text);
197 internal void Error(
string Text)
199 if (this.hasSnifferSet)
201 if (this.isAuthenticated)
202 this.snifferSet!.Error(this.userName, Text);
204 this.unauthenticatedSniffer?.
Error(Text);
212 internal void Exception(Exception Exception)
214 if (this.hasSnifferSet)
216 if (this.isAuthenticated)
217 this.snifferSet!.Exception(this.userName, Exception);
219 this.unauthenticatedSniffer?.
Exception(Exception);
230 lock (this.subscriptions)
232 return this.subscriptions.Contains(Uri);
243 lock (this.subscriptions)
245 return this.subscriptions.Add(Uri);
256 lock (this.subscriptions)
258 return this.subscriptions.Remove(Uri);
Capabilities of the client.
Describes the MCP implementation.
void Dispose()
Disposes the connection
string SessionId
MCP Session ID
bool Unsubscribe(string Uri)
Unsubscribes from a resource.
string ClientProtocolVersion
Protocol version of client.
bool IsSubscribed(string Uri)
Checks if a subscription to a resource exists.
string UserName
User name used for session.
async Task DisposeAsync()
IDisposableAsync.DisposeAsync()
Implementation? ClientInformation
Information about client, if available.
Session(string SessionId, string ClientProtocolVersion, ClientCapabilities? ClientCapabilities, Implementation? Implementation, string RemoteEndpoint, ISnifferSet? SnifferSet)
MCP Session information.
void TransmitText(string Text)
Text has been transmitted to the client.
string RemoteEndpoint
Client remote endpoint.
bool Subscribe(string Uri)
Subscribes to a resource.
bool IsAuthenticated
If client has been authenticated in the session.
ClientCapabilities? ClientCapabilities
Client capabilities, if available.
Sniffer that stores events in memory.
void Replay(CommunicationLayer ComLayer)
Replays sniffer events.
override Task DisposeAsync()
IDisposableAsync.DisposeAsync
void Warning(string Warning)
Called to inform the viewer of a warning state.
void Error(string Error)
Called to inform the viewer of an error state.
void TransmitText(string Text)
Called when text has been transmitted.
void Exception(string Exception)
Called to inform the viewer of an exception state.
void Information(string Comment)
Called to inform the viewer of something.
void ReceiveText(string Text)
Called when text has been received.
Maintains a set of sniffers.
Interface for asynchronously disposable objects.
Interface for JSON-RPC session objects.
Interface for sets of sniffers.