signalr 2.0

26
Applicazioni Real- Time con SignalR Emanuele Bartolesi Senior SharePoint Consultant [email protected] @kasuken

Upload: emanuele-bartolesi

Post on 18-Nov-2014

795 views

Category:

Technology


0 download

DESCRIPTION

 

TRANSCRIPT

Page 1: SignalR 2.0

Applicazioni Real-Time con SignalR

Emanuele BartolesiSenior SharePoint Consultant [email protected]@kasuken

Page 2: SignalR 2.0

#WebAndBeyond

Page 3: SignalR 2.0

Sponsor

Page 4: SignalR 2.0

L’evoluzione del web

Siti Statici HTML

Pagine dinamiche, forms

Aggiornamenti parziali pagine (ajax), RIA

Applicazioni Real Time

Page 5: SignalR 2.0

Social Network

Page 6: SignalR 2.0

Actions

Page 7: SignalR 2.0

Stock Tickers

Page 8: SignalR 2.0

Web Chats

Page 9: SignalR 2.0

Altre applicationi• Live scores• Giochi• Apps collaborative (Office 365)• Statistiche live

Page 10: SignalR 2.0

Soluzioni?• Polling (Ajax)• Long Polling• Server-Sent events (HTML5)• WebSockets (HTML5)

Soluzioni poco realizzabili

e difficili

Page 11: SignalR 2.0

Chi ci può aiutare?

O SignalR

Page 12: SignalR 2.0

Cosa è SignalR?• Tecnologia UFFICIALE Microsoft per

realizzare applicazioni real time e multi utente: http://signalr.net

• Soluzione client e server• Non ci dobbiamo concentrare sul canale di

trasmissione• OpenSource (potete andare a vedere come

è scritto!)

Page 13: SignalR 2.0

Priorità Trasmissione

WebSockets

Server-Sent events

Forever Frame (IE hack)

Long Polling

Page 14: SignalR 2.0

Architettura

Client sideJS, .NET/WinRT, WP, Silverlight, iOS/Android

Hub API

PersistentConnection API

Page 15: SignalR 2.0

Hubs• High-level API• Simile ai Controller

(actions, thread per call)

Page 16: SignalR 2.0

Scenari supportati• Client calling the server• Server calling clients (all, group,

one)• State round-tripping between client

and server• Binding complex objects (JSON)• Detecting connect, disconnect and

reconnect clients• Broadcasting from outside of a Hub• Async scenarios (return

Task/Task<T> to client)

Page 17: SignalR 2.0

Il server chiama il client• dynamic Clients property• JSON serialization

Page 18: SignalR 2.0

Chiamate dall’esterno• Notify clients from another

server-side code

Page 19: SignalR 2.0

Client JavaScript• $.connection.hub

• connection for all hubs (url points to /signalr)• $.connection.hub.id

• client id for the hub connection• $.connection.hub.start()

• starts the connection for all hubs• $.connection.{hubname}

• access a client side hub from the generated proxy

Page 20: SignalR 2.0

Esporre i metodi sul client• Il client JavaScript può dichiarare metodi che possono

essere invocati dal server:

• myHub.{method} = callback• method - nome del metodo client• callback - funzione da eseguire quando il server

invoca il metodo

Page 21: SignalR 2.0

Autenticazione• Si può usare il meccanismo di

autenticazione di ASP.NET• Si può utilizzare l’attributo “Authorize” per

gli Hubs• Autenticazione Forms e Windows• Supporta i certificati https

Page 22: SignalR 2.0

Cosa realizzeremo?

Page 23: SignalR 2.0

demo

Demo

Page 24: SignalR 2.0

#WebAndBeyond

Page 25: SignalR 2.0

Grazie

Page 26: SignalR 2.0

© 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted

to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.