Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ public void Dispose()
_client.Reconnecting -= OnReconnecting;
_client.ConnectionStateChanged -= OnConnectionStateChanged;
}

_networkMonitor.NetworkAvailabilityChanged -= OnNetworkAvailabilityChanged;
}

public void SetReconnectStrategySettings(ReconnectStrategy reconnectStrategy, float? exponentialMinInterval,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ public async Task DisconnectAsync(bool permanent = false)

public void Update(float deltaTime)
{
_networkMonitor?.Update();

#if !STREAM_TESTS_ENABLED
_updateCallReceived = true;
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void Update()
return;
}

var wasReachable = IsReachable(_lastState.Value);
var wasReachable = IsReachable(prevLastState.Value);

if (wasReachable && !isReachable)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,6 @@ protected void Awake()
}
}

protected void Update()
{
if (_client == null || _missingCredentials)
{
return;
}

var isClientConnectedOrConnecting = _client.ConnectionState == ConnectionState.Connected ||
_client.ConnectionState == ConnectionState.Connecting;

var isNetworkReachable =
Application.internetReachability == NetworkReachability.ReachableViaCarrierDataNetwork ||
Application.internetReachability == NetworkReachability.ReachableViaLocalAreaNetwork;

if (!isClientConnectedOrConnecting && isNetworkReachable)
{
Debug.LogWarning("Client is not connected, but network is reachable. Force reconnect.");
_client.ConnectUserAsync(_authCredentialsAsset.Credentials);
}
}

private IStreamChatClient _client;
private bool _missingCredentials;

Expand Down