The following lists the important points for server side here:
- SignalR 2.0 uses Open Web Interface (OWIN) for .NET as the standard interface
between .NET web servers and web applications, enabling a level of indirection and
abstraction that keeps your project from directly tying to any specific hosting platform.
This is the technical foundation that actually enables SignalR to be hosted from both
web applications and traditional .NET processes, as we'll see later.
- Every OWIN application must have a Startup class that follows specific conventions.
In particular, a Configuration() method with the signature shown in the
preceding code must be made available.
- The assembly-level attribute OwinStartup is there to declare that our Startup
class will be used to bootstrap every OWIN-based asset contained in all the loaded
assemblies; there are other ways to declare the right Startup class to load, but
we'll see them in the future recipes.
- Inside the Configuration() method, we start up SignalR using an appropriate
extension method (MapSignalR()) made available by the SignalR core inside the
Owin namespace; a call to the MapSignalR() method will expose an endpoint
called /signalr, which the clients will use to connect to the server.
The main points of client side scripts:
- Add a Hub class. Any class available in the project that is derived from
Hub is automatically discovered and exposed when SignalR is initialized calling
MapSignalR in the Startup class.
- The client page established a connection to the Hub using the JavaScript
SignalR client library.
- When the connection is ready, make a remote call to the xxx() method
exposed by the custom Hub.
- SignalR coordinates the two sides using the most appropriate connection strategy
taking into account which is the HTTP server hosting
the application and which web browser is used to run the client page; it gives us
the feeling of a direct connection towards our server-side Hub, allowing us to call
methods on it directly (the line hub.server.xxx('xxx SignalR!');).
No comments:
Post a Comment