Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do i pass a parameter to a function im calling in the SignalR connection.invoke method?

I need to pass some data to the function i wanna render, but i dont know the syntax to do so.

Code:

var connection = new signalR.HubConnectionBuilder().withUrl("/hubFilas").build();

connection.start().then(function () {
    var time = setInterval(function () {
        connection.invoke("renderComponent").then(function (o) { DisplayHub(o) }).catch(function (err) {
            return console.error(err.toString());
        });
    }, 120000)

Any ideas?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You just pass the data as parameter to the invoke call. As described in the docs for sample hub:

public class ChatHub : Hub
{
    public async Task SendMessage(string user, string message)
        => await Clients.All.SendAsync("ReceiveMessage", user, message);
}

You can invoke the method via following call:

connection.invoke("SendMessage", user, message);

Also check out:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading