After the new Event Hub connection request has been created, we are ready to connect to the Event Hub.
function connectToEventHub(endpoint, id)
{
var connection = new signalR.HubConnectionBuilder()
.withUrl(endpoint,
{
accessTokenFactory: () => {
return id;
}
})
.build();
connection.on("Event", function (message) {
console.log(message);
});
connection.start().then(function () {
console.log("Connected to Event Hub!");
}).catch(function (err) {
return console.error(err.toString());
});
}