Real Time Data in Web Applications

Similar documents
Sitecore Dashboard User Guide

This course provides students with the knowledge and skills to develop ASP.NET MVC 4 web applications.

ASP.NET SignalR Incredibly simple real-time features for your web apps

70-487: Developing Windows Azure and Web Services

Repeater. BrowserStack Local. browserstack.com 1. BrowserStack Local makes a REST call using the user s access key to browserstack.

socketio Documentation

Mobile Push Architectures

All You Can Eat Realtime

Bringing M2M to the web with Paho

WebSocket Server. To understand the Wakanda Server side WebSocket support, it is important to identify the different parts and how they interact:

Practical ASRNET. Web API. Badrinarayanan Lakshmiraghavan. Apress*

Integrating Mobile apps with your Enterprise

Bayeux Protocol: la nuova frontiera della comunicazione a portata di mano. Relatore Nino Guarnacci

MS 10978A Introduction to Azure for Developers

Real Time Data Communication over Full Duplex Network Using Websocket

Introduction to Building Windows Store Apps with Windows Azure Mobile Services

High Performance Messaging for Web-based Trading Systems. Frank Greco Director of Technology, Kaazing

Developing ASP.NET MVC 4 Web Applications MOC 20486

Mobile development with Apache OFBiz. Ean Schuessler, Brainfood

Shipbeat Magento Module. Installation and user guide

What about MongoDB? can req.body.input 0; var date = new Date(); do {curdate = new Date();} while(curdate-date<10000)

Working with Indicee Elements

Using the VMRC Plug-In: Startup, Invoking Methods, and Shutdown on page 4

Setup Guide: Server-side synchronization for CRM Online and Exchange Server

Cloud Powered Mobile Apps with Azure

Developing a Web Server Platform with SAPI Support for AJAX RPC using JSON

Collaborative Open Market to Place Objects at your Service

PROTECTING DATA IN TRANSIT WITH ENCRYPTION IN M-FILES

GCM for Android Setup Guide

Performance Testing for Ajax Applications

Let s Chat! (Part 1)

Developing ASP.NET MVC 4 Web Applications

Novacura Flow 5. Technical Overview Version 5.6

Course 10978A Introduction to Azure for Developers

Minimal network traffic is the result of SiteAudit s design. The information below explains why network traffic is minimized.

Server-Side JavaScript auf der JVM. Peter Doschkinow Senior Java Architect

White Paper March 1, Integrating AR System with Single Sign-On (SSO) authentication systems

HTML5 Websockets with ruby and rails. Saurabh Bhatia, CEO, Safew Labs

Single Sign On. SSO & ID Management for Web and Mobile Applications

Introduction to Azure: Microsoft s Cloud OS

Software Development Interactief Centrum voor gerichte Training en Studie Edisonweg 14c, 1821 BN Alkmaar T:

Crestron Fusion Version 9.3 Enterprise Management Platform Installation Guide

10978A: Introduction to Azure for Developers

Dragan Juričić, PBZ May 2015

Developing Windows Azure and Web Services

Dovico Timesheet v12 INSTALLATION GUIDE

Securing ArcGIS Server Services: First Steps

1. Introduction. 2. Web Application. 3. Components. 4. Common Vulnerabilities. 5. Improving security in Web applications

Hangfire Documentation

HTML5. Eoin Keary CTO BCC Risk Advisory.

System Area Management Software Tool Tip: Integrating into NetIQ AppManager

WSO2 Message Broker. Scalable persistent Messaging System

Step into the Future: HTML5 and its Impact on SSL VPNs

Budget Event Management Design Document

Web Caching and CDNs. Aditya Akella

WebLogic & Coherence. Best backend for Mobile Apps. July 2014 INSERT PRESENTER TITLE AND DATE

Getting Started with Telerik Data Access. Contents

Developing ASP.NET MVC 4 Web Applications Course 20486A; 5 Days, Instructor-led

Cloud Powered Mobile Apps with Microsoft Azure

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

OPAS Prerequisites. Prepared By: This document contains the prerequisites and requirements for setting up OPAS.

BlackBerry Enterprise Server for IBM Lotus Domino Version: 4.1 Service Pack: 7. Installation Guide

CRM Developer Form

A distributed system is defined as

CONSUL AS A MONITORING SERVICE

Customer Bank Account Management System Technical Specification Document

A Survey Study on Monitoring Service for Grid

Web Applications Testing

Total Application Instances - Details 11/28/ :00:00-12/4/ :59:59

Device Log Export ENGLISH

Architecture and Data Flow Overview. BlackBerry Enterprise Service Version: Quick Reference

Research of Web Real-Time Communication Based on Web Socket

Building a CloudStack UI for the Enterprise

ASP.NET Using C# (VS2012)

SharePoint 2010 Performance and Capacity Planning Best Practices

Salesforce Mobile Push Notifications Implementation Guide

Category: Business Process and Integration Solution for Small Business and the Enterprise

Lessons from Building Asterisk GUIs. Presented by Gaston Draque

Developing Microsoft SharePoint Server 2013 Advanced Solutions. Version: Demo. Page <<1/8>>

BSA Best Practices Webinars Role Based Access Control Sean Berry Customer Engineering

PrivateWire Gateway Load Balancing and High Availability using Microsoft SQL Server Replication

Building WebRTC Solutions with the Avaya WebRTC Collaboration Environment Snap-in. Joel Ezell Lead Architect, Collaboration Environment R&D

Introduction to Azure for Developers

MS 20487A Developing Windows Azure and Web Services

Developing Microsoft Azure Solutions 20532B; 5 Days, Instructor-led

How To Write A Web Server In Javascript

Outline SOA. Properties of SOA. Service 2/19/2016. Definitions. Comparison of component technologies. Definitions Component technologies

Research on Server Push Methods in Web Browser based Instant Messaging Applications

Transcription:

Martin Schreiber push push push

Agenda 1. Real Time Data and HTTP? HTTP AJAX WebSockets 2. Getting Started with ASP.NET SignalR 2.x RPC Connection Transport Behavior Server JavaScript Client.NET Client Security DI 3. Unit Testing of SignalR Hubs Callback Invocation Mocking 4. Real Life / Scale Out of SignalR Apps Live Demo Backplane 5. Q & A 2 5/21/2015

Real Time Data and HTTP? 3 5/21/2015

HTTP: Synchronous, Delayed, Server Load Client Server "Real Time" Data Source Polling Interval Block HTTP Request HTTP Response Notification HTTP Request Delay HTTP Response Block Notification 4 5/21/2015

AJAX: Delay, Server Load Client Server "Real Time" Data Source Polling Interval (Block) HTTP Request (synchronous) HTTP Response AJAX Request (async) Delay Notification AJAX Response Notification AJAX Request (async) AJAX Response Notification 5 5/21/2015

WebSockets: Server-Push, Real Time Client Server "Real Time" Data Source (Block) WS: Connect (HTTP) WS: Connected WS: Event WS: Event (Delay) Notification Notification WS: Event Notification 6 5/21/2015

Getting Started with ASP.NET SignalR 2.x 7 5/21/2015

SignalR: Framework for remote procedure calls (RPC) Server-to-client: call JavaScript in client browsers from server-side.net code. Client-to-server: call server-side.net code from JavaScript in client browsers. 8 5/21/2015

SignalR Connection Persistent unlike the classic HTTP (reestablished per request) Connection management supports reconnect on connection loss Broadcast server-push rather than request-response Server to specific client Server to all clients (thousands; see scale-out) Server to groups of clients 2 Levels of abstraction PersistentConnection class hides connection/transport details; message-based. Hub class hides client addressing details (groups etc.); operation-based. 9 5/21/2015

SignalR Transport WebSockets (based on TCP) Client: http://caniuse.com/#feat=websockets ( ) Server:.NET 4.5, IIS 8 (Windows Server 2012 Windows 8), Windows Azure Automatic Fallback on connection while connection HTTP WebSockets (server memory efficiency, lowest latency, duplex communication) Server Sent Events (HTML5; except IE) Forever Frame (only IE; 1 connection for request; 1 for responding scripts) Ajax long polling ( server delays response until data is available; or timeout occurs. Client reconnects.) Manual selection @ connection open connection.start({ transport: [ 'websockets', 'serversentevents', 'foreverframe', 'longpolling ] }); 10 5/21/2015

Parts on SignalR Server and JavaScript Client IAppBuilder.MapSignalR() // "/signalr/hubs" Hub public class MyHub : Hub { public void /*Task*/ MyMethod(<client data>) { // Clients.All.myMethod(<push data>); Clients.AllExcept(<connectionId>, ).mymethod( ); Clients.Caller.myMethod( ); Clients.Client(<connectionId>).myMethod( ); Clients.Clients(<connectionId>, ).mymethod( ); Clients.Group(<group name>).mymethod( ); Clients.Groups(<group name>, ).mymethod( ); Clients.Others.myMethod( ); Clients.OthersInGroup(<group name>).mymethod( ); Clients.OthersInGroups(<group name>, ).mymethod( ); Clients.User(<user id>).mymethod( ); Clients.Users(<user id>, ).mymethod( ); 11 5/21/2015

Parts on SignalR Server and JavaScript Client <script src=" /jquery-2.1.1.min.js"/> <script src=" /jquery.signalr-2.x.min.js"/> <script src="/signalr/hubs"/> <!-- if outside asp.net app --> <script src="http://<host>/signalr/hubs"/> // configure, if asp.net signalr app: $.connection.hub.url = "http://<host>/signalr"; var myhubproxy = $.connection.myhub; // register call-backs myhubproxy.client.mymethod = function (<server push data>) { /* call-back */ }; // connect $.connection.hub.start().done( function () { /* wire up */ }).fail( function () { /* handle err */ }); // invoke hub method myhubproxy.server.mymethod(<client data>).done( function () { /*... */ }).fail( function () { /* handle err */ }); // 12 5/21/2015

Parts on a.net Client (same on the Server) // any.net application // ---- conceptually the same as in JavaScript ---- // configure, if asp.net signalr app; get (generic) proxy. var hubconnection = new HubConnection("http://<host>/signalr"); IHubProxy myhubproxy = hubconnection.createhubproxy("myhub"); // register call-backs myhubproxy.on<<server push data>>( "MyMethod", <server push data> => /* handle call-back */ ); // connect await hubconnection.start(); // invoke hub method myproxy.invoke("mymethod", <client data>); // 13 5/21/2015

SignalR Security SignalR uses Authentication of the hosting App Hubs [Authorize( )] on hub class, and/or hub method. [Authorize(RequireOutgoing = false)] outgoing calls w/o authorization. GlobalHost.HubPipeline.RequireAuthentication(); enforce global auth. Override AuthorizeAttribute.UserAuthorized( ) for custom authorization. PersistentConnection Override <Connection>.AuthorizeRequest(IRequest request). 14 5/21/2015

SignalR Dependency Injection SignalR creates hubs for you > no control over instantiation Register function for Constructor Injection : GlobalHost.DependencyResolver.Register( typeof(myhub1), () => new MyHub1(<dependency>)); IoC Containers Unity.WebApi container.registerinstance<<dependency interface>>(new <dependency()>); GlobalConfiguration.Configuration.DependencyResolver = new UnityDependencyResolver(<container>); Unity.Mvc5, Ninject, Castle Windsor, Spring.Net, Autofac, StructureMap 15 5/21/2015

Unit Testing of SignalR Hubs 16 5/21/2015

SignalR Hub under Test: Callback invocation? IHubCallerContext<dynamic> Clients.Others.broadcastMessage( string resourcekey, ResourceStatus status );? 17 5/21/2015

Live Demo I: Add Hub to Project; Test-Driven Adding a Hub to ASP.NET SignalR Project, Unit-Test Client Contract Preparation: ASP.NET Web Application Msugs2015.RealTimeWeb.SignalRApp Empty, [x] Add Unit tests PM> install-package Microsoft.AspNet.SignalR (2x) PM> install-package Moq (in test project) Demo: Add new Hub, define Client and Server Contracts Setup Unit Test. Verify Callbacks to Clients are invoked. 18 5/21/2015

Real Life / Scale Out of SignalR Apps 19 5/21/2015

Live Demo II: Resource Status Notification ASP.NET SignalR App Observe Notify Resources Observer Notify SignalR Hub WEB API Controller Subscribe to Resource Status Notify Satus Changes Request Resource HTML/JavaScript Client Hub Proxy Invoke REST Client (AJAX) Data Sink Resource Manager (Cache, DB,...) CRUD Resource PUT/POST Resource Data Source REST Client (.NET) 20 5/21/2015

Scale Out? 21 5/21/2015

Scale Out: Backplane Backplane SignalR App sends Message to Backplane Backplane sends Msg to each SignalR App IMessageBus (pub/sub abstraction) Backplane Services Azure Service Bus ( Azure messaging infrastructure; $ ) Redis http://redis.io/ ( In-Memory key-value store, supports Pub/Sub, Replication etc. ) SQL Server Message Broker ( Messages in Tables ) 22 5/21/2015

Q&A Read more at http://www.asp.net/signalr Martin Schreiber martin.schreiber@trivadis.com 23 5/21/2015