I need to set connection id before hubConnection.start(); I look here https://github.com/SignalR/SignalR/wiki/SignalR-JS-Client and what i found: connection.id - Gets or sets the client id for the current connection. Tried this. No working. Here is the client code:
let hubUrl = 'http://localhost:5000/chat';
let hubConnection = new signalR.HubConnectionBuilder()
.withUrl(hubUrl)
.configureLogging(signalR.LogLevel.Information)
.build();
hubConnection.id = "12345";
hubConnection.on("Send", function (data) {
let elem = document.createElement("p");
elem.appendChild(document.createTextNode(data));
let firstElem = document.getElementById("chatroom").firstChild;
document.getElementById("chatroom").insertBefore(elem, firstElem);
});
document.getElementById("sendBtn").addEventListener("click", function (e) {
let message = document.getElementById("message").value;
hubConnection.invoke("Send", message);
});
hubConnection.start();
hubConnection.id = "12345"; this do not change real connection id. And maybe you are know some other way how to write client-side connection?