1

Topic: SignalR

All kind time of days!
Faced the following problem.
Is MVC (web) application in which it is used SignalR for mailing of various notification messages to users.
Connection to a hub and mailing function are described on the master to page.
All works as well as should work. The user receives messages being on any page of application.
But it was required to add on several pages different functions with usage SignalR.
That I made:
Actually too most, as on the master to page.

var hub = $.connection.myHub;
hub.client.updateModule = function (param1, param2) {...}
hub.client.updateModuleTwo = function (param1, param2) {...}
$.connection.hub.start ()
.done (function () {
...
})
.fail (function () {
...
});

So the good set forth above refused to work.
According to the documentation on SignalR: "Before to start a hub, it is necessary to register event handlers"
[spoiler]
Normally you register event handlers before calling the start method to establish the connection. If you want to register some event handlers after establishing the connection, you can do that, but you must register at least one of your event handler (s) before calling the start method. One reason for this is that there can be many Hubs in an application, but you would not want to trigger the OnConnected event on every Hub if you are only going to use to one of them. When the connection is established, the presence of a client method on a Hub's proxy is what tells SignalR to trigger the OnConnected event. If you do not register any event handlers before calling the start method, you will be able to invoke methods on the Hub, but the Hub's OnConnected method will not be called and no client methods will be invoked from the server.
[/spoiler]
And so it turns out that on the master to page, I register event handlers and I start a hub. All apprx. Mailing of notification messages works.
I come on other page where it is necessary to use the above described functional and it does not work!
I make comments signalR on the master to page, the above described functional works as it is necessary.
I transfer the above described functional on the master page, all works as it is necessary!!
I.e. it is possible to draw an output that all events used in the project worked correctly, it is necessary to register them before the first start of a hub.
The subsequent starts of a hub and event are ignored.
To carry out all functional on the master page not really.
Who what will have reasons and-or experience on this point in question??

2

Re: SignalR

RAVen42 wrote:

who what will have reasons and-or experience on this point in question??

Make the intermediate manager which collects the registration data from page, then registers.

3

Re: SignalR

hVostt wrote:

Make the intermediate manager which collects the registration data from page, then registers.

It is a variant certainly. But found the decision easier
[url=https://stackoverflow.com/questions/25945136/signalr-how-to-add-client-call-after-the-hub-is-started/25951324#25951324] SignalR: How to add client call after the hub is started?
[/url]
In the documentation about it it is not told, and it would be necessary to tell.

4

Re: SignalR

RAVen42 wrote:

It is a variant certainly. But found the decision easier
[url=https://stackoverflow.com/questions/25945136/signalr-how-to-add-client-call-after-the-hub-is-started/25951324#25951324] SignalR: How to add client call after the hub is started?
[/url]

On me so-so the decision. Anyway, it is desirable to write the manager and to hide  behind it, for many reasons.
And without the manager, the master  can define section for registration by pages of the hubs. In general of decisions mass, and on your link it is similar to a crutch.

5

Re: SignalR

hVostt wrote:

in general of decisions mass, and on your link it is similar to a crutch.

It agree that it is similar to a crutch, but only at first sight. Actually, with the manager or without, usage of a hub from a proxy or without matters. In the documentation unfortunately it is not described in what a difference. And the difference is also it very essential.

6

Re: SignalR

RAVen42 wrote:

Actually, with the manager or without, usage of a hub from a proxy or without matters.

Well, but it is clear and without the documentation if know JavaScript.