I am making an app separating client and function app and used azure signalR service. I can broadcast message to all clients but cannot send message to individual users. I have found some solutions but they did not worked on my case.
This is my Negotiate function.
public class Negotiate : ServerlessHub
{
[FunctionName("negotiate")]
public SignalRConnectionInfo GetSignalRInfo(
[HttpTrigger(AuthorizationLevel.Anonymous, "post")] HttpRequest req,
[SignalRConnectionInfo(HubName = "chat", UserId = "{headers.x-ms-client-principal-id}")] SignalRConnectionInfo connectionInfo)
{
return connectionInfo;
}
}
And my clinet side connection is :
const apiBaseUrl = 'http://localhost:7071';
const connection = new signalR.HubConnectionBuilder()
.withUrl(`${apiBaseUrl}/api`, {
headers: {
"x-ms-client-principal-id": userName
}
})
.configureLogging(signalR.LogLevel.Information)
.build();
The problem i am facing is i am unable to bind the headers in negotiate.