Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
signalr / SignalR Programming in Microsoft ASP.NET.pdf
Скачиваний:
65
Добавлен:
25.05.2015
Размер:
19.23 Mб
Скачать

Unfortunately, for reasons related to the structural scalability of SignalR, we cannot obtain information about the groups, such as the list of connections included in them, not even how many there are. Neither can we know, a priori, what groups are active at a given moment. If we want to include these aspects in our applications, we must implement them ourselves, outside SignalR.

The OWIN startup class

We have previously seen where to enter the mapping and configuration code of our persistent connections and, in general, of any middleware based on OWIN. We will now go back to that briefly, to go over some details that were left pending.

When an OWIN-based system starts up, the host process on which it is executed will try to execute configuration code that must be implemented in a member predefined by convention. By default, it will try to execute the Configuration() method of the Startup class, which must be located in the root namespace of the application. However, to adapt it to our preferences, it is possible to modify this convention in one of the following ways:

■■Specifying the class and the method that we want to employ by using the assembly attribute

OwinStartup:

[assembly:OwinStartup(typeof(MyApp.MyStartupClass), methodName: "MyConfigMethod")]

■■Including the entry “owin:AppStartup” in the <AppSettings> section of the .config file of the application and setting as a value the fully qualified name of the class and the method to be used:

<configuration>

<appSettings>

...

<add key="owin:AppStartup" value="MyApp.MyStartupClass.MyConfigMethod"/>

</appSettings>

...

</configuration>

In either case, the configuration method can be static or an instance method (although in the latter case the class must have a public constructor without parameters), and it must necessarily be defined with an IAppBuilder parameter:

namespace MyApp

{

public class MyStartupClass

{

public void MyConfigMethod(IAppBuilder app)

{

// Configure OWIN app here

}

}

}

Persistent connectionsChapter 4

37

www.it-ebooks.info

Соседние файлы в папке signalr