Skip to content

Remote client result does not work. #14

@aetos382

Description

@aetos382

Calling client with the following code will result in an exception.

var groupProvider = new RemoteGroupProvider(
    DynamicInMemoryProxyFactory.Instance,
    DynamicRemoteProxyFactory.Instance,
    new TestJsonRemoteSerializer(),
    new RemoteClientResultPendingTaskRegistry());

using var group = groupProvider.GetOrAddGroup<int, IReceiver>("name");
await group.AddAsync(0, new Receiver(100));

var receiver = group.Single(0);

// Throws System.NotSupportedException: 'In-memory proxy does not support to invoke multiple receivers.'
var x = await receiver.NotifyAsync().ConfigureAwait(false);

Console.WriteLine($"Received: {x}");

public interface IReceiver
{
    Task<int> NotifyAsync();
}

class Receiver(int value) : IReceiver
{
    public Task<int> NotifyAsync()
    {
        Console.WriteLine("Notify");
        return Task.FromResult(value);
    }
}

I think it is because _targets in InMemoryProxyBase is null.

private void ThrowIfNotSingle()
{
if (_targets is not { Length: 1 })
{
throw new NotSupportedException("In-memory proxy does not support to invoke multiple receivers.");
}
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions