I have several SignalR Hubs each with several methods. Mostly with a CRUD like signature i.e.
string AddNode(Node node);
void RemoveNode(string id);
void UpdateNode(Node node);
Node GetNode(string id);
List<Node> GetNodes();
Now every now and then I have to add more methods to a Hub or to add overloads and things start to play up. The wrong methods get called and I just can work out what is going on. I normally end up creating a new Hub to deal with the new methods.
The only thing I can put it down to is my method names have a namespace in them as follows;
[HubMethodName(XPortConst.Methods.GetNode)]
public void GetNode(SRGetNodeReq req)
{
...
}
where
public const string XportConst.Methods.GetNode = "Xport.Method.GetNode";
So, can the HubMethodName be given a string with "dots" in it?
Could all my methods have the name "XPort" and simply still be workign due to the method parameters being different?
Let's say you do this
It means you would call this method from JS code as
nodeHub.server.A.B.C(req);
Your generated signalr/hubs class must declare a function called A.B.Cwhich will fail with
Uncaught SyntaxError: Unexpected token .
You cannot have '.' in JS function name.How about replacing to '_'?
A_B_C
would be no problem in this case. Also, I would say creating multiple Hub classes is not a bad thing actually.