Skip to content

Commit

Permalink
Updated channelWaiter class, added logger to the same
Browse files Browse the repository at this point in the history
  • Loading branch information
sacOO7 committed Aug 10, 2023
1 parent ba1e9e9 commit c0b7d05
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/IO.Ably.Shared/Realtime/ChannelAwaiter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ internal class ChannelAwaiter : IDisposable
private readonly object _lock = new object();
private readonly Action _onTimeout;

public ChannelAwaiter(IRealtimeChannel channel, ChannelState awaitedState, ILogger logger = null, Action onTimeout = null)
public ChannelAwaiter(IRealtimeChannel channel, ChannelState awaitedState, ILogger logger, Action onTimeout = null)
{
Logger = logger ?? DefaultLogger.LoggerInstance;
Logger = logger;
_name = $"#{channel.Name}:{awaitedState} awaiter";
_channel = channel as RealtimeChannel;
_awaitedState = awaitedState;
Expand Down
4 changes: 2 additions & 2 deletions src/IO.Ably.Shared/Realtime/RealtimeChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ internal RealtimeChannel(
string name,
string clientId,
AblyRealtime realtimeClient,
ChannelOptions options = null,
ChannelOptions options,
IMobileDevice mobileDevice = null)
: base(options?.Logger)
: base(options.Logger)
{
Name = name;
Options = options;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class CountdownTimer : ICountdownTimer, IDisposable

public CountdownTimer(string name, ILogger logger)
{
_logger = logger ?? DefaultLogger.LoggerInstance;
_logger = logger;
_name = name;
_lock = new object();
}
Expand Down
4 changes: 2 additions & 2 deletions src/IO.Ably.Tests.Shared/Realtime/ChannelSandboxSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ public async Task WhenSubscribingToAChannelWithInsufficientPermissions_ShouldSet
// do nothing
});

var result = await new ChannelAwaiter(channel, ChannelState.Failed).WaitAsync();
var result = await new ChannelAwaiter(channel, ChannelState.Failed, client.Logger).WaitAsync();
await Task.Delay(100);
result.IsSuccess.Should().BeTrue();

Expand Down Expand Up @@ -1017,7 +1017,7 @@ public async Task WhenAttachingToAChannelFromMultipleThreads_ItShouldNotThrowAnE

await Task.WhenAll(task, task2);

var result = await new ChannelAwaiter(channel, ChannelState.Attached).WaitAsync();
var result = await new ChannelAwaiter(channel, ChannelState.Attached, client1.Logger).WaitAsync();
result.IsSuccess.Should().BeTrue();
}

Expand Down
2 changes: 1 addition & 1 deletion src/IO.Ably.Tests.Shared/Realtime/ChannelsSpecs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public async Task ReleaseAll_ShouldRemoveChannelWhenDetached()
// Act
client.FakeProtocolMessageReceived(new ProtocolMessage(ProtocolMessage.MessageAction.Detached, TestChannelName));

await new ChannelAwaiter(channel, ChannelState.Detached).WaitAsync();
await new ChannelAwaiter(channel, ChannelState.Detached, client.Logger).WaitAsync();

// Assert
client.Channels.Should().BeEmpty();
Expand Down
2 changes: 1 addition & 1 deletion src/IO.Ably.Tests.Shared/Rest/SandboxSpecExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ internal static async Task WaitForState(this IRealtimeChannel channel, ChannelSt
return;
}

var channelAwaiter = new ChannelAwaiter(channel, awaitedState);
var channelAwaiter = new ChannelAwaiter(channel, awaitedState, channel.Options.Logger);
var timespan = waitSpan.GetValueOrDefault(TimeSpan.FromSeconds(5));
Result<bool> result = await channelAwaiter.WaitAsync(timespan);
if (result.IsFailure)
Expand Down

0 comments on commit c0b7d05

Please sign in to comment.