I'm having trouble to get return value from SignalR server-to-client call inside a Web API controller. There are many similar questions for getting return value from server-to-client call. I followed this solution where .NET Core 2 is used.
However I am using .NET 6, just couldn't make it work. Could you please help with it, any help will be appreciated.
This is my Web API controller with SignalR server:
[Route("api/[controller]")]
[ApiController]
public class MiniAppController : ControllerBase
{
private readonly IHubContext<RpcHub> _rpcHubContext;
private readonly ILogger<RpcHub> _logger;
public MiniAppController(IHubContext<RpcHub> rpcHubContext, ILogger<RpcHub> logger)
{
_rpcHubContext = rpcHubContext;
_logger = logger;
}
[HttpGet]
public async Task<ActionResult<MethodResponse>> Checkout(string comID, string parkServerID, string parkLotID, string parkID, string miniAppID, string miniUserID, string sign)
{
string userId = comID + parkServerID + parkLotID;
MethodResponse response = await _rpcHubContext.Clients.Client("1-1-010").MethodCall(new MethodParams
{
MethodCallId = new Guid(),
Name = "Walker",
Age = 30
});
return Ok(response);
}
}
I'm getting compilation error:
Error: CS1061 “IClientProxy” doesn't include “MethodCall”definition,couldn't find the first class “IClientProxy” parameter accessiable extension method “MethodCall”(lacking using statement or assembly)