Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 443 Vote(s) - 3.51 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Signalr error on namechange

#1
So I just started off trying to work with Signalr for a project I'm working on. I have fairly little experience with JScript or Jquery, but a decent amount of experience with C#

I made the tutorial project on microsoft docs for a chat app [over here][1].

So this is probably a fairly dumb question in the eyes of most.

in the script I replaced

chat.server.Send($('#displayname').val(), $('#message').val());
with

chat.server.GetServerName($('#displayname').val(), $('#message').val());

and in the hub added the function

public void GetServerName(string name, string message)
{
// Call the broadcastMessage method to update clients.
Clients.All.broadcastMessage(name, message);
}

But I'm getting the following error.

> Uncaught TypeError: chat.server.GetServerName is not a function

If all the rest of the project is identical, how does this happen?

My apologies if this is a duplicate, I've been looking for almost 5 hours with no sensible answer to my question elsewhere that I'm aware of.

[1]:

[To see links please register here]

Reply

#2
Normally you need to start the method name in lowercase when calling from SignalR client

chat.server.getServerName($('#displayname').val(), $('#message').val());


Replace **GetServerName** with **getServerName**
Reply

#3
Use invoke method of the Hub to call server methods from the client:

yourHub.Invoke("GetServerName", $('#displayname').val(), $('#message').val());
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through