Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Assets/Plugins/StreamChat/Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Fixes:
Unreleased:
Features:

* Add IStreamChatClient.SuspendConnectionAsync, which closes the websocket but keeps the user session and the reconnect schedule. Use it when you know the client is about to stop pumping Update (e.g. an app being backgrounded): messages are received on a background timer thread but only handled from Unity's main loop, so a stalled pump lets the receive queue fill with nothing draining it. Watched channels are preserved and the reconnect fires on the next update tick, re-hydrating missed events. Contrast with DisconnectUserAsync, which ends the session permanently and cannot be resumed without connecting the user again.
* Add a public StreamApiException constructor (statusCode, code, errorMessage, moreInfo, duration, exceptionFields). StreamApiException is a public, catch-and-branch type (via the StreamApiExceptionExtensions.Is* helpers), but until now it could only be constructed inside the SDK from the internal APIErrorInternalDTO, so integrators could not build one to unit-test their own error handling (e.g. simulating a 403 / code 70 "no access to channels" response). The new constructor maps directly to the type's public properties and keeps APIErrorInternalDTO internal.
* Add IStreamClientConfig.OptimisticMessageInsert (default true). When true (the existing behavior), a message you send is inserted into the local channel state and raised via IStreamChannel.MessageReceived immediately, before the server's message.new echo arrives. Set it to false to skip the optimistic local insert and wait for the server echo instead, so every participant - including the sender - observes messages in the same server-defined order. Useful when consistent cross-client ordering matters more than instant local feedback (e.g. a shared, broadcast-ordered feed).

Expand Down
11 changes: 11 additions & 0 deletions Assets/Plugins/StreamChat/Core/IStreamChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,17 @@ Task<StreamDeleteChannelsResponse> DeleteMultipleChannelsAsync(IEnumerable<IStre

Task DisconnectUserAsync();

/// <summary>
/// Closes the websocket but keeps the user session and the reconnect schedule,
/// for when the caller knows the client is about to stop pumping <see cref="Update"/> (an
/// app being backgrounded). Stops the background receive timer so no unbounded backlog
/// builds up while nothing is draining it. Watched channels are preserved and the
/// reconnect fires on the next update tick, re-hydrating missed events. Contrast with
/// <see cref="DisconnectUserAsync"/>, which ends the session permanently and cannot be
/// resumed without connecting the user again.
/// </summary>
Task SuspendConnectionAsync();

bool IsLocalUser(IStreamUser messageUser);

/// <summary>
Expand Down
5 changes: 5 additions & 0 deletions Assets/Plugins/StreamChat/Core/StreamChatClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@ public Task DisconnectUserAsync()
return InternalLowLevelClient.DisconnectAsync(permanent: true);
}

// permanent: false is the whole point — it leaves the ReconnectScheduler armed
// so the connection comes back on its own once Update ticks again.
/// <inheritdoc/>
public Task SuspendConnectionAsync() => InternalLowLevelClient.DisconnectAsync(permanent: false);

public async Task<StreamCurrentUnreadCounts> GetLatestUnreadCountsAsync()
{
var dto = await InternalLowLevelClient.InternalChannelApi.GetUnreadCountsAsync();
Expand Down
Loading