# MentorHubClient class

> Typed wrapper around HubConnection for the Novior.MentorAgent.Server hub. Manages connection lifecycle with automatic exponential-backoff reconnect.

- URL: https://docs.mentoragent.net/api/novior-mentoragent-blazor-hub/mentorhubclient
- Verified with: MentorAgent 1.2.0
- Last updated: 2026-10-27
- Packages: Novior.MentorAgent.Blazor

## Definition

Namespace: `Novior.MentorAgent.Blazor.Hub`. Package: `Novior.MentorAgent.Blazor`.

`public sealed class MentorHubClient : IAsyncDisposable`

```shell
dotnet add package Novior.MentorAgent.Blazor
```

## Constructors

`public MentorHubClient(MentorAgentBlazorOptions options, ILogger<MentorHubClient> logger)`

Connects to [`MentorAgentBlazorOptions.HubUrl`](https://docs.mentoragent.net/api/novior-mentoragent-blazor-models/mentoragentblazoroptions#huburl) as written. A relative `HubUrl` is not resolved here: use the constructor that takes the `NavigationManager`, which `AddMentorAgentBlazor()` picks in WebAssembly.

`public MentorHubClient(MentorAgentBlazorOptions options, NavigationManager navigation, ILogger<MentorHubClient> logger)`

Connects to [`MentorAgentBlazorOptions.HubUrl`](https://docs.mentoragent.net/api/novior-mentoragent-blazor-models/mentoragentblazoroptions#huburl), resolving a relative value such as the default `"/mentor-hub"` against the page's base address, as a browser does.

## Properties

### `ConnectionId`

`public string? ConnectionId { get; }`

Id of the live SignalR connection, or `null` when disconnected. Needed by the out-of-band HTTP endpoints (`/mentor/cancel`) that must reach this connection's orchestrator without going through the hub.

### `IsConnected`

`public bool IsConnected { get; }`

## Methods

### `CancelRequestAsync`

`public Task CancelRequestAsync(CancellationToken ct = default)`

### `DisposeAsync`

`public ValueTask DisposeAsync()`

### `On`

`public IDisposable On<T>(string methodName, Action<T?> handler)`

`public IDisposable On(string methodName, Action handler)`

`public IDisposable On<T1, T2>(string methodName, Action<T1?, T2?> handler)`

`public IDisposable On<T1, T2, T3>(string methodName, Action<T1?, T2?, T3?> handler)`

### `ResetSessionAsync`

`public Task ResetSessionAsync(CancellationToken ct = default)`

### `RespondToApprovalAsync`

`public Task RespondToApprovalAsync(string requestId, bool approved, CancellationToken ct = default)`

### `SendMessageAsync`

`public Task SendMessageAsync(string text, CancellationToken ct = default)`

`public Task SendMessageAsync(string text, IReadOnlyList<MentorAttachment>? attachments, CancellationToken ct = default)`

### `SendUserMessageAsync`

`public Task SendUserMessageAsync(MentorUserMessage message, CancellationToken ct = default)`

Sends a user turn with its images and its language, to the hub's `SendUserMessage`.

### `StartAsync`

`public Task StartAsync(CancellationToken ct = default)`

### `UpdatePageContextAsync`

`public Task UpdatePageContextAsync(PageContextSnapshot snapshot, CancellationToken ct = default)`

---

- Previous: [ClientServiceExtensions class](https://docs.mentoragent.net/api/novior-mentoragent-blazor-extensions/clientserviceextensions.md)
- Next: [MentorAgentBlazorOptions class](https://docs.mentoragent.net/api/novior-mentoragent-blazor-models/mentoragentblazoroptions.md)
