Date post: | 08-Apr-2017 |
Category: |
Engineering |
Upload: | luca-zulian |
View: | 323 times |
Download: | 3 times |
Web e device in real time con ASP.NET SignalRGiuseppe MarchiMicrosoft MVP SharePoint
Luca ZulianMCTS ASP.NET 4
What is SignalR?Under the Hood
Building Apps with SignalR
SignalR outside .NET Framework
_1
_3
_5
_18
Performance & testing _21
What is SignalR for Developers?
• A library for ASP.NET developers that simplifies the process of adding real-time functionality
• An Open Source library (github.com/SignalR/SignalR)
• Well Documented library (asp.net/signalr)• Always up to date
What SignalR offers to Developers
• Real-time, persistent connection abstraction over HTTP for .NET (supports Web Sockets, and falls back to other compatible techniques for older browsers)
• Simplicity• Reach• Performance• Scalability• Security• Extensibility
SignalR: under the hood
Before Start: Components• Meta Package (Microsoft.AspNet.SignalR)• Core (Microsoft.AspNet.SignalR.Core)• Hosts (Microsoft.AspNet.SignalR.SystemWeb,
Microsoft.AspNet.SignalR.Owin)• Clients (Microsoft.AspNet.SignalR.Js,
Microsoft.AspNet.SignalR.Client)• Scaleout Buses
(Microsoft.AspNet.SignalR.Redis, Microsoft.AspNet.SignalR.ServiceBus)
DEMO
Simplicity: two level APIChoose the level of abstraction that works for you
Two level API: ConfigurationRemember: call RouteTable.Routes.MapHubs() as the first line of code in the Application_Start method, this must be called before you register any other routes.
Two level API: Hub ConfigurationRemember: call RouteTable.Routes.MapConnection() as the first line of code in the Application_Start method, this must be called before you register any other routes.
Two level API: PersistentConnection
• Low-level• Simple endpoint for sending
single-recipient, grouped, or broadcast messages
• Gives direct access to the low-level communication protocols
• PersistentConnection class
• Connect, reconnect & disconnect semantics
Two level API: PersistentConnection
PersistentConnection API
Two level API: PersistentConnection
DEMO
Two level API: Hub• More high-level pipeline• Allows your client and
server to call methods each other directly (internal routing)
• Allows you to pass strongly typed parameters to methods, enabling model binding
• Hub class• Automatic client proxy
generation (Javascript)
Two level API: HubHub API
Two level API: Hub
DEMO
Simplicity: Javascript client• Javascript proxy (AUTOMATICALLY created on
~/signalr/hubs)
Simplicity: Windows8 & WP8 client
• Microsoft.AspNet.SignalR.Client• Hub
• PersistentConnection
Transport NegotiationSignalR isolates us from low-level details, giving us the impression of working on a permanently open persistent connection
But isn’t real-time web just chat?
• Dashboards & monitoring• Collaborative anything• Job progress• Real-time forms• Gaming• …
SignalR outside .NET framework
• SignalR-ObjC - Native for iOS clients
• SignalA - Native for Android clients
• Xamarin (in xamarin branch https://github.com/SignalR/SignalR/tree/xamarin, but need some tricks)
SignalR on IIS?Supported server operating systems• Windows Server 2012• Windows Server 2008 r2.• Windows 8• Windows 7• Windows Azure
Supported .NET Framework versions• SignalR is supported on both .NET Framework version 4 and 4.5. For
WebSockets to be supported, .NET Framework 4.5 must be used.
Supported IIS versions• IIS 8 or IIS 8 Express• IIS 7 and 7.5. Support for extensionless URLs is required• IIS must be running in integrated mode; classic mode is not supported• The hosting application must be running in full trust mode
SignalR only on IIS?
• Console Applications, Windows Services (Microsoft.AspNet.SignalR.SelfHost)
• OWIN (Microsoft.AspNet.SignalR.Owin)
• Mono
SignalR performance & testing
• SignalR Crank or Stress projects from repository
• Performance Monitor (Perfmon.exe)
SignalR performance & testing
• Connections Connected
• Connections Reconnected
• Connections Disonnected
• Connections Current• Connection Messages
Received Total• Connection Messages
Sent Total• Connection Messages
Received/Sec• Connection Messages
Sent/Sec
SignalR Performance Counter
SignalR performance considerations
Reducing message size• JsonIgnore attribute• JsonProperty attribute to reduce message size
Modify SignalR configuration settings• DefaultMessageBufferSize
Modify ASP.NET configuration settings• Maximum concurrent requests per CPU• Request Queue Limit
Modify IIS configuration settings• Max concurrent requests per application
Q&A
Contatti
OverNet Education• TEL. +39 02 365738• EMAIL [email protected]• WEB www.WPC2013.it• TWITTER @Overnete
Thank You