Page tree
Skip to end of metadata
Go to start of metadata

This hub created to let you get general ideas working with SignalR. There are nothing special. It does not even require you to be authenticated.

To get fully working code navigate to https://MyWebAPI.com/DemoSignalR/Test and get page source code.

To access hub you can get a link to it:

const connection = new signalR.HubConnectionBuilder()
    .withUrl('https://MyWebAPI.com/hubs/test/v1')
    .configureLogging(signalR.LogLevel.Debug)
    .build();

Method 'ping(string)'

You can pass any string to this method:

connection
    .invoke("Ping", "test message")
    .then(() => console.log("Ping request sent"))
    .catch(err => console.error(err));

Server will be returned back through client side callback 'pong' exactly the same you have sent there:

connection.on("pong",
    function(msg) {
        console.log("pong: " + msg);
    });

Get server time

Each second server will send its time through client side callback as of:

connection.on("onClock",
    function(clock) {
        console.log(clock);
    });
  • No labels