Upload
robin-sedlaczek
View
703
Download
1
Embed Size (px)
DESCRIPTION
Slides from my talk about the Microsoft SignalR framework.
Citation preview
SignalRRobin Sedlaczek
Robin Sedlaczek15 Jahre Erfahrung als Entwickler
8 Jahre Erfahrung als Projektleiter
seit 4 Jahren CTO und Gesellschafter bei der Fairmas GmbH in Berlin
Autor für Windows Developer & DotNetPro
MSDN Community-Mitglied/Moderator
MVA Contributor (.NET Compiler Plattform)
Contributor bei SharpGL (GitHub)
twitter.com/RobinSedlaczek
robinsedlaczek.wordpress.com
SignalR
Was ist SignalR?
- Framework für Echtzeitkommunikation im Internet- API für RPC (Server to Client)- benutzt WebSockets, Long Polling, Server Sent Events, Forever Frame etc.- persistente Connections- automatisches Connection Management (connect, disconnect, grouping)- Broadcasts oder Messages einzelnen Clients- Open Source unter .NET Foundation (http://www.dotnetfoundation.org/)- Code auf GitHub (https://github.com/SignalR)
Einsatzgebiete
- häufiges Aktualisieren einer Webseite durch den Benutzer- Dashboards- Monitoring-Anwendungen- Echtzeit-Formulare- Kollaborative Anwendungen (z.B. sowas wie Google Docs)- Real-Time Gaming
OWIN & KATANA
OWIN => Spezifikation aus der Community (owin.org)
KATANA =>Referenzimplementierung von Microsoft
Quelle: Microsoft
Quelle: Microsoft
Unterstützte Betriebssysteme
Windows Server 2012
Windows Server 2008 r2
Windows 8
Windows 7
Windows Azure
Unterstützte IIS-Versionen IIS 8 or IIS 8 Express.
IIS 7 and 7.5 with support for extensionless URLs is required.
IIS must be running in integrated mode; classic mode is not supported. Message delays of up to 30 seconds may be experienced if IIS is run in classic mode using the Server-Sent Events transport.
The hosting application must be running in full trust mode.
Browser-Anforderungen
Transport Internet Explorer
Chrome(Windows or iOS)
Firefox Safari (OSX or iOS) Android
WebSockets 10+ current - 1 current - 1 current - 1 N/A
Server-Sent Events N/A current - 1 current - 1 current - 1 N/A
ForeverFrame 8+ N/A N/A N/A 4.1
Long Polling 8+ current - 1 current - 1 current - 1 4.1
Attention: jQuery version 1.6.4 or major later versions (such as 1.7.2, 1.8.2, or 1.9.1) required!
Desktop/Silverlight-Anforderungen
Transport .NET Application Silverlight
Web Sockets Windows 8+ and .NET 4.5+ N/A
Forever Frame N/A N/A
Server-Sent Events .NET 4+ 5+
Long Polling .NET 4+ 5+
Windows Store/Phone-Anforderungen
Transport Windows Store/ .NET
Windows Store/ JavaScript
Windows Phone/IE
Windows Phone/.NET
WebSockets N/A Win8+ 8+ N/A
Forever Frame N/A Win8+ 7.5+ N/A
Server-Sent Events Win8+ N/A N/A 8+
Long Polling Win8+ Win8+ 7.5+ 8+
Demo
Tracing
Tracing - NachrichtentypenSource Messages
SignalR.SqlMessageBus SQL Message Bus scaleout provider setup, database operation, error, and timeout events
SignalR.ServiceBusMessageBus Service bus scaleout provider topic creation and subscription, error, and messaging events
SignalR.RedisMessageBus Redis scaleout provider connection, disconnection, and error events
SignalR.ScaleoutMessageBus Scaleout messaging events
SignalR.Transports.WebSocketTransport WebSocket transport connection, disconnection, messaging, and error events
SignalR.Transports.ServerSentEventsTransport ServerSentEvents transport connection, disconnection, messaging, and error events
SignalR.Transports.ForeverFrameTransport ForeverFrame transport connection, disconnection, messaging, and error events
SignalR.Transports.LongPollingTransport LongPolling transport connection, disconnection, messaging, and error events
SignalR.Transports.TransportHeartBeat Transport connection, disconnection, and keepalive events
SignalR.ReflectedHubDescriptorProvider Hub discovery events
Demo
Tracing - Konfiguration- in Anwendungskonfigurationsdatei (app.config, web.config) für Server- im Client so
_connection.TraceLevel = TraceLevels.All; _connection.TraceWriter = Console.Out;
oder:
var writer = new StreamWriter("SignalRClient.log");writer.AutoFlush = true;
_connection.TraceLevel = TraceLevels.All; _connection.TraceWriter = writer;
Security
Security
- SignalR besitzt keinen eigenen Authentifizierungsmechanismus- unterliegt dem Anwendungs-Authentifizierungsmechanismus (z.B.
Forms Authentication, oAuth etc.)- stellt das Authorize-Attribut zur Verfügung
Quelle: Microsoft
Quelle: Microsoft
Security
- SignalR benutzt Connection Token in jedem Request- Connection Token besteht aus Connection Id und Username- Connection Token wir mit jedem Request verifiziert
Frage: Wie kommt SignalR zu einen Username?
Cookie-AuthentifizierungCookie cookie = AuthenticateUser(username, password);
var connection = new HubConnection(url); connection.CookieContainer = new CookieContainer(); connection.CookieContainer.Add(cookie); connection.Start().Wait();
private Cookie AuthenticateUser(object username, object password){ Cookie cookie = null; // Get Cookie from FormsAuthentication response. return cookie; }
Windows-Authentifizierung
var connection = new HubConnection(url);
connection.Credentials = CredentialCache.DefaultCredentials; connection.Start().Wait();
Header-Authentifizierung
var connection = new HubConnection(url);
connection.Headers.Add("myauthtoken", /* token data */); connection.Start().Wait();
Zertifikat-Authentifizierung
var connection = new HubConnection(url);
connection.AddClientCertificate( X509Certificate.CreateFromCertFile("MyCert.cer")); connection.Start().Wait();
Demo