Skip to content

Instantly share code, notes, and snippets.

@xximjasonxx
Last active May 2, 2020 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xximjasonxx/61b7dda31e848567b3f7ebb15068c936 to your computer and use it in GitHub Desktop.
Save xximjasonxx/61b7dda31e848567b3f7ebb15068c936 to your computer and use it in GitHub Desktop.
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@aspnet/signalr@1.1.0/dist/browser/signalr.min.js"></script>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
var connection = new signalR.HubConnectionBuilder()
.withUrl('https://func.azurewebsites.net/api')
.configureLogging(signalR.LogLevel.Information)
.build();
// Create a function that the hub can call to broadcast messages.
connection.on('newFirstLetterData', (name, message) => {
$("#reportOutput").append(`<div class="entry">${JSON.stringify(message)}</div>`);
});
connection.start()
.then(() => {
alert("connected");
})
.catch((error) => {
alert("connection failed");
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment