Skip to content
Client v5: BLE, BLE Hosting, HTTP, Jobs - Linux, MacOS, & Blazor Support! Full AOT, RX on BLE only & MANY other features! Power up!

ChatView | Typing & Connection

ChatView shows animated typing dots when a remote user is composing. Two halves: the control tells you when the current user is typing, and you tell the control when other users are typing.

As the user types, the control debounces and calls:

Task ToggleTypingAsync(bool isTyping, CancellationToken ct = default);

It sends true when typing begins and false on send or after an inactivity timeout. Broadcast this to other participants over your transport. (In a purely local provider there’s nothing to broadcast.)

public Task ToggleTypingAsync(bool isTyping, CancellationToken ct = default)
{
// forward to your hub/transport so the other participants see the indicator
return this.hub.SendTypingAsync(this.SessionId, this.CurrentUserId, isTyping, ct);
}

When a remote participant’s typing state changes, raise UserTyping:

public record UserTypingEvent(string UserId, bool IsTyping, DateTimeOffset Timestamp);
this.UserTyping?.Invoke(this, new UserTypingEvent(remoteUserId, isTyping: true, DateTimeOffset.Now));

The control handles the rest:

  • Debounce of the outbound ToggleTypingAsync.
  • Expiry of stale inbound indicators (if a false never arrives, the dots time out on their own).
  • Rendering the "{Name} is typing…" pill / animated dots, scroll-aware.
PropertyTypeDefaultDescription
ShowTypingIndicatorbooltrueEnable/disable typing indicators entirely

Raise ConnectionStateChanged whenever your transport’s connectivity changes:

public enum ChatConnectionState { Connected, Reconnecting, Offline }
this.ConnectionStateChanged?.Invoke(this, ChatConnectionState.Reconnecting);
// ...later...
this.ConnectionStateChanged?.Invoke(this, ChatConnectionState.Connected);

The control reacts automatically:

StateUI
Connectedno banner; input bar enabled (subject to CanSendMessages)
Reconnectingbanner shown; input bar disabled
Offlinebanner shown; input bar disabled

There is no offline queue — sends are only attempted while Connected. A send that still fails transiently becomes MessageStatus.Failed (with retry); a provider rejection becomes MessageStatus.Rejected (no retry). See Messages & Paging.