Progressive .NET Tutorials, July 3rd, London, UK

Slides:



Advertisements
Similar presentations
IoT with SignalR & .NET Gadgeteer
Advertisements

Java Script Session1 INTRODUCTION.
Nikola Dimitroff Creating Genres creatinggenres.com.
Building Real Time Applications with ASP.NET SignalR 2.0
SignalR Real Time with SignalR Jared Rhodes Senior Consultant Magenic.
JQuery. What is jQuery? jQuery is a fast, small, and feature-rich JavaScript library that simplifies HTML document traversing and manipulation event handling.
Presented by…. Group 2 1. Programming language 2Introduction.
Kay Herzam Herzam IT Consulting What‘s new in ASP.NET MS TechTalk.
IT 210 The Internet & World Wide Web introduction.
Web & Cloud Development Jason Keicher - Microsoft.
REAL WORLD SPA A KNOCKOUT CASE STUDY Cory House | bitnative.com | speakerrate.com/talks/27181.
WebSockets [intro].
JavaScript & jQuery the missing manual Chapter 11
1 What Can HTML5 WebSocket Do For You? Sidda Eraiah Director of Management Services Kaazing Corporation.
Real Time Mobile Apps using Xamarin and SignalR
 You’re already a Web Site Dev  You’re interested in more simply making your web sites more responsive  If you’re not already hosting sites in.
08 | What’s Next and Resources Jon Galloway | Tech Evangelist Christopher Harrison | Head Geek.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
Web Engineering we define Web Engineering as follows: 1) Web Engineering is the application of systematic and proven approaches (concepts, methods, techniques,
JavaScript. Overview Introduction: JavaScript basics Expressions and types Expressions and types Arrays Arrays Objects and Associative Arrays Objects.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
Tracker data quality monitoring based on event display M.S. Mennea – G. Zito University & INFN Bari - Italy.
1 Type Sensitive Application of Mutation Operators for Dynamically Typed Programs Leonardo Bottaci Department of Computer Science University of Hull, Hull,
Esri UC 2014 | Demo Theater | Configuring the Live,Work, Locate Application Nikki Golding.
Zz SOCKET.IO going real time with Arnout Kazemier
CISC 3140 (CIS 20.2) Design & Implementation of Software Application II Instructor : M. Meyer Address: Course Page:
The Client-Server Model And the Socket API. Client-Server (1) The datagram service does not require cooperation between the peer applications but such.
M Machine Learning F# and Accord.net.
INT222 - Internet Fundamentals Shi, Yue (Sunny) Office: T2095 SENECA COLLEGE.
ASP.NET SignalR SoftUni Team Technical Trainers Software University
Plug-in Architectures Presented by Truc Nguyen. What’s a plug-in? “a type of program that tightly integrates with a larger application to add a special.
AJAX Asynchronous JavaScript and XML 1. AJAX Outline What is AJAX? Benefits Real world examples How it works 2.
A Technical Overview Bill Branan DuraCloud Technical Lead.
WebRTC Don McGregor Research Associate MOVES Institute
Node.Js 1. 2 Contents About Node.Js Web requirement latest trends Introduction Simple web server creation in Node.Js Dynamic Web pages Dynamic web page.
AJAX AJAX Asynchronous JavaScript and XML --- MADHAVI
The Internet What is the Internet? The Internet is a lot of computers over the whole world connected together so that they can share information. It.
Overview Web Technologies Computing Science Thompson Rivers University.
Keith Telle Lead Software Engineer Bit Wizards Behind the Magic: SignalR Demystified.
Mail Web Twitter TypeScript Rainer Stropek software architects gmbh JavaScript on Steroids.
//liveVirtualacademy2011/ What’s New for ASP.NET 4.5 and Web Development in Visual Studio 11 Developer Preview Γιώργος Καπνιάς MVP, MCT, MCDP, MCDBA, MCTS,
Web Application Development Process
Windows Communication Foundation and Web Services
Build and Learn ASP.NET Workshop.
WebSockets and Equinox OSGi in a Servlet Container
Real-Time GIS Leveraging Stream Services
Web Technologies Computing Science Thompson Rivers University
WebSockets: TCP in Javascript
CSE 154 Lecture 11: AJAx.
Tutorial 10 Programming with JavaScript
z/Ware 2.0 Technical Overview
ASP.NET SignalR SoftUni Team C# MVC Frameworks Technical Trainers
CHAPTER 9 APIS. CHAPTER 9 APIS WHAT IS AN API?
Windows Communication Foundation and Web Services
Welcome to your first Online Session
Client-Server Interaction
Building real-time web apps with WebSockets using IIS, ASP.NET and WCF
CSE 154 Lecture 11: AJAx.
JavaScript an introduction.
DWR: Direct Web Remoting
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
03 | Building a Backend with Socket.IO and Mongo
Building event-driven, long-running apps with Windows workflow
ISC440: Web Programming 2 AJAX
CS3220 Web and Internet Programming JavaScript Basics
Web Technologies Computing Science Thompson Rivers University
Lighting Up Real-time Web Communications with SignalR Introduction
Presentation transcript:

Progressive .NET Tutorials, July 3rd, London, UK Reactive Interactive visualization of F# jobs Alena Dzenisenka Progressive .NET Tutorials, July 3rd, London, UK

Alena dzenisenka @lenadroid Software architect at Luxoft Poland Member of F# Software Foundation Board of Trustees Researcher in the field of mathematical theoretical possible in modern programming concepts Speaker and Active software engineering community member @lenadroid

Contents Why is dynamic data visualization important? Why F# for working with data? Approaches to web based dynamic visualization. Examples .

Data here . Data there . Data everywhere .

Why F# for working with data?

F# Exploratory programming, interactive environment Functional programming paradigm Immutability, pattern Matching, type inference, higher order functions, computation expressions, type providers, … Prototyping and modeling, dsls Concurrent programming Distributed and cloud programming Frameworks and libraries

powerful and beautiful visualization on the web ?

Javascript

D3. js Highcharts C3. js Chartist. js Chart D3.js Highcharts C3.js Chartist.js Chart.js Zing Chart Ember Charts Vis.js xCharts Amcharts Sigma.js Leaflet Dygraphs.js Springy.js Cubism.js FusionCharts Google Visualization API Raphael.js Polymaps

Actions with data Data Analytics, computations, etc. Visualization somewhere Actions with data Analytics, computations, etc. (generates new data too) Data Visualization

Very persistent… … much full-duplex so server push… …wow… websockets

Application Hubs api Persistent connection api transports

Transport Long polling Forever frames Web sockets Server Sent Events

Hosting Signalr server Self hosting SignalR in console application outside of Iis for less overhead during F# jobs. owin – decoupling .NET servers and web Applications owin.Cors - cross-domain support, when SignalR and a web client are hosted in different domains.

first set up type public Startup() = member public this.Configuration(app) = let config = new HubConfiguration() config.EnableDetailedErrors <- true Owin.MapExtensions.Map(app, "/signalr", fun map -> Owin.CorsExtensions.UseCors(map, Microsoft.Owin.Cors.CorsOptions.AllowAll) |> ignore Owin.OwinExtensions.RunSignalR(map, config)) |> ignore

cross-domain calls using CoRS Owin.CorsExtensions.UseCors(map, Microsoft.Owin.Cors.CorsOptions.AllowAll) detailed error messages config.EnableDetailedErrors <- true Choose transport scheme $.connection.hub.start( { transport: ['webSockets', 'longPolling'] });

hubs

Hubs – strong typing ♥ type IClient = abstract member addMessage: string -> string -> unit   [<HubName("fsharpHub")>] type public FsharpHub() as this = inherit Hub<IClient>() member public x.Send(name : string, message: string) = this.Clients.All.addMessage name message |> ignore

Kicking off the server [<EntryPoint>] let main argv = let url = "http://localhost:8080/" use app = WebApp.Start<Startup>(url) Console.WriteLine("Server running on {0}", url) let context : IHubContext = GlobalHost.ConnectionManager.GetHubContext<FsharpHub>() Console.ReadLine() |> ignore

Javascript part

. Live updates .

Live updates Data – Popularity by states and browsers type PopularityByStates = { State: string; browsers: PopularityByBrowsers } // Count of users online [<DataContract>] type PopularityByBrowsers = { [<field: DataMember(Name="Chrome")>] Chrome: int [<field: DataMember(Name="Firefox")>] Firefox: int [<field: DataMember(Name="Safari")>] Safari: int [<field: DataMember(Name="IE")>] IE: int }

onconnect schema exchange [<HubName("fsharpHub")>] type public FsharpHub() as this = inherit Hub<ClientHub>() override this.OnConnected() = let exchangeObject = [| { State = "California"; Browsers = { Chrome = 0; Firefox = 0; Safari = 0; IE = 0} }; // ... other schema data |] this.Clients.Caller.exchangeSchema(JsonConvert.SerializeObject(exchangeObject)) |> ignore base.OnConnected() // ...other hub methods

Javascript mission with received schema hub.client.exchangeSchema = function (schema) { var schemaJs = JSON.parse(schema); // do required setup using schema data manually or cast it to JS prototype instead // and work with it instead function iterate(obj, stack) { for (var property in obj) { if (obj.hasOwnProperty(property)) { if (typeof obj[property] == "object") { iterate(obj[property], stack + '.' + property); } else { console.log(property + " " + obj[property]); // jQuery('#output').append(jQuery("<div/>").text(stack + '.' + property)) } iterate(schemaJs, '') // Do anything else required with received type for initial JS-side set up. // ...

. Live updates .

. Time series data from the cloud .

MBrace

Getting our clouds ready Setting connection strings: let myStorageConnectionString = "your connection string" let myServiceBusConnectionString = "your connection string" let config = { Configuration.Default with StorageConnectionString = myStorageConnectionString ServiceBusConnectionString = myServiceBusConnectionString } Getting Mbrace runtime: let cluster = Runtime.GetHandle(config) cluster.ShowProcesses() cluster.ShowWorkers() cluster.AttachClientLogger(ConsoleLogger())

Getting our clouds ready Defining Cloud ChannelS: let channel = cluster.StoreClient.Channel let sendPort1, receivePort1 = channel.Create<TimeSeries []>() let sendPort2, receivePort2 = channel.Create<TimeSeries []>() Getting Mbrace runtime: let updates (receive : IReceivePort<TimeSeries []>) (send : ISendPort<TimeSeries []>) = cloud { while true do let! result = Cloud.Catch <| receive.Receive() match result with | Choice1Of2 x -> let timeSeries = getTimeSeriesDataFor result do! send.Send timeSeries // e.g. {x = 1434994711; y = 81.2406} | Choice2Of2 _ -> () } let job = cluster.CreateProcess(updates receivePort1 sendPort2)

Send something to the cloud ! Define the destination where we’d like to send data: let connection = new HubConnection("http://localhost:8080") let fsharpHub = connection.CreateHubProxy "fsharpHub" let sendSomething message = async { return! channel.SendAsync(sendPort1, message) } let receiveMessages = async { while true do let! result = channel.ReceiveAsync(receivePort2) sendUpdatesTimeSeries fsharpHub result printfn "Received: %A" result } connection.Start().Wait() Send messaGEs to the cloud and receive responses: Start the connection before calling receive messages:

Update clients with fresh data let sendUpdatesTimeSeries (hub: IHubProxy) (message) = let x = JsonConvert.SerializeObject(message) hub.Invoke<string>("timeSeries", x).ContinueWith(fun (t : Task) -> if t.IsFaulted then Console.WriteLine("Could not Invoke method: {0}", t.Exception.GetBaseException()) else Console.WriteLine("Success calling timeSeries method")) |> ignore

. Time series data .

. Voting server .

. Voting hUB . [<HubName("voteHub")>] type public VoteHub() as this = inherit Hub() override this.OnConnected() = //... this.Clients.Caller.exchangeSchema(schemaObject) |> ignore base.OnConnected() member public x.Vote(room: string, percent: int) = // ... this.Clients.Group(room)?addMessage(room, votingService.RoomResults.Head.PercentOfAgree) |> ignore member public x.ClosePoll(room: string) = votingService.RoomResults.Head.PercentOfAgree, "disconnect") member public x.JoinRoom(room: string) = this.Groups.Add(this.Context.ConnectionId, room) member public x.LeaveRoom(room: string) = this.Groups.Remove(this.Context.ConnectionId, room)

SignalR type provideR Server hub definition: [<HubName("somehub")>] type SomeHub() = inherit Hub() member this.Send(x: string) = x + "!" Client definition: let signalR = Globals.Dollar.signalR let serverHub = new Hubs.somehub(signalR.hub) serverHub.Send ("string")

. ThanK you .