SignalR 2.0

Post on 18-Nov-2014

795 views 0 download

Tags:

description

 

Transcript of SignalR 2.0

Applicazioni Real-Time con SignalR

Emanuele BartolesiSenior SharePoint Consultant emanuele@smartcoretech.com@kasuken

#WebAndBeyond

Sponsor

L’evoluzione del web

Siti Statici HTML

Pagine dinamiche, forms

Aggiornamenti parziali pagine (ajax), RIA

Applicazioni Real Time

Social Network

Actions

Stock Tickers

Web Chats

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

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

Soluzioni poco realizzabili

e difficili

Chi ci può aiutare?

O SignalR

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!)

Priorità Trasmissione

WebSockets

Server-Sent events

Forever Frame (IE hack)

Long Polling

Architettura

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

Hub API

PersistentConnection API

Hubs• High-level API• Simile ai Controller

(actions, thread per call)

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)

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

Chiamate dall’esterno• Notify clients from another

server-side code

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

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

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

Cosa realizzeremo?

demo

Demo

#WebAndBeyond

Grazie

© 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.