Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.

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

To get fully working code navigate to and get page source code.

To access hub you can get a link to it:

Code Block
varconst hubconnection = $.connection.testnew signalR.HubConnectionBuilder()

Method 'ping(string)'

You can pass any string to this method:

Code Block
languagejs"anything you want, current date and time, for example")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:

Code Block
// declare client-side callback
hub.client.pong = 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:

Code Block
// declare client-side callback
hub.client.onClock = connection.on("onClock",
    function(clock) {