Last post Jul 24, 2015 09:00 AM by danielvc
Jul 23, 2015 03:39 PM|danielvc|LINK
I just initiatet to use SignalR and I have the following doubt:
Is a Hub created by different IP?
I ask this because, I've developed the map to list all users connected, however, if I connect using a different computer, or even a mobile, the user is inserted in another list.
I have Computer A, Computer B, Mobile C.
If I connect in 2 different browsers in the computer A, on debugging, I have a list of 2 connected ID.
If I connect in 1 browser in the computer B, looks like that there is a new hub, and my list of mapped users appears only 1 user (this one that I just connected on computer B);
Looks like that there isn't a unique list that has ALL connected users.
Is that right?
It's supposed to be ONE hub for one IP?
Jul 24, 2015 05:07 AM|progi|LINK
You don't instantiate the Hub class or call its methods from your own code on the server; all that is done for you by the SignalR Hubs pipeline. SignalR creates a new instance of your Hub class each time it needs to handle a Hub operation such as when a
client connects, disconnects, or makes a method call to the server.
Because instances of the Hub class are transient, you can't use them to maintain state from one method call to the next. Each time the server receives a method call from a client, a new instance of your Hub class processes the message. To maintain state
through multiple connections and method calls, use some other method such as a database, or a static variable on the Hub class, or a different class that does not derive from Hub. If you persist data in memory, using a method such as a static
variable on the Hub class, the data will be lost when the app domain recycles.
If you want to send messages to clients from your own code that runs outside the Hub class, you can't do it by instantiating a Hub class instance, but you can do it by getting a reference to the SignalR context object for your Hub class. For more information,
see How to call client methods and manage groups from outside the Hub classlater in this topic.
Jul 24, 2015 09:00 AM|danielvc|LINK
Thank you for sharing me these informations. I found the problem. In my computer, I had 2 virtual applications addressed to the same folder. In computer A, I was acessing app
http://servicili.com (localhost site A), and in the computer B and mobile C, I was acessing
http://myip (Default web site)