Accueil
Explorer
Soumettre la recherche
Mettre en ligne
S’identifier
S’inscrire
Publicité
Check these out next
SignalR Overview
Michael Sukachev
Signalr with ASP.Net part2
Esraa Ammar
Clean up this mess - API Gateway & Service Discovery in .NET
Marcin Tyborowski
Enjoying the Move from WCF to the Web API
Kevin Hazzard
Architecting &Building Scalable Secure Web API
SHAKIL AKHTAR
Encode x NEAR: Technical Overview of NEAR 1
KlaraOrban
Web Real-time Communications
Alexei Skachykhin
Building Fast and Scalable Persistence Layers with Spring Data JPA
VMware Tanzu
1
sur
40
Top clipped slide
SignalR
18 Sep 2012
•
0 j'aime
10 j'aime
×
Soyez le premier à aimer ceci
afficher plus
•
4,215 vues
vues
×
Nombre de vues
0
Sur Slideshare
0
À partir des intégrations
0
Nombre d'intégrations
0
Signaler
Technologie
SignalR Communication
Eyal Vardi
Suivre
Freelance Consultant & Entrepreneur at Var d; à var d;
Publicité
Publicité
Publicité
Recommandé
SignalR with asp.net
Martin Bodocky
10.7K vues
•
18 diapositives
SignalR With ASP.Net part1
Esraa Ammar
850 vues
•
32 diapositives
Real time Communication with Signalr (Android Client)
Deepak Gupta
10.2K vues
•
38 diapositives
Intro to signalR
Mindfire Solutions
1.5K vues
•
26 diapositives
Introduction to SignalR
Anthony Peruma
1.7K vues
•
39 diapositives
Introduction to SignalR
Adam Mokan
7.1K vues
•
16 diapositives
Contenu connexe
Présentations pour vous
(20)
SignalR Overview
Michael Sukachev
•
2.1K vues
Signalr with ASP.Net part2
Esraa Ammar
•
451 vues
Clean up this mess - API Gateway & Service Discovery in .NET
Marcin Tyborowski
•
217 vues
Enjoying the Move from WCF to the Web API
Kevin Hazzard
•
6.5K vues
Architecting &Building Scalable Secure Web API
SHAKIL AKHTAR
•
2.7K vues
Encode x NEAR: Technical Overview of NEAR 1
KlaraOrban
•
132 vues
Web Real-time Communications
Alexei Skachykhin
•
1.4K vues
Building Fast and Scalable Persistence Layers with Spring Data JPA
VMware Tanzu
•
584 vues
Building API-Driven Microservices with Amazon API Gateway - AWS Online Tech T...
Amazon Web Services
•
6.3K vues
Aws Technical Day 2015 - Amazon API Gateway
aws-marketing-il
•
326 vues
Asp.Net Core MVC , Razor page , Entity Framework Core
mohamed elshafey
•
322 vues
Server Sent Events, Async Servlet, Web Sockets and JSON; born to work together!
Masoud Kalali
•
11.4K vues
Server-Sent Events in Action
Andrei Rusu
•
12.4K vues
Server side
philipsinter
•
590 vues
Web services - A Practical Approach
Madhaiyan Muthu
•
10.3K vues
Developing and Hosting SOAP Based Services
StephenKardian
•
144 vues
AWS July Webinar Series - Overview Build and Manage your APs with amazon api ...
Amazon Web Services
•
3.2K vues
10 Tricks and Tips for WCF
Barry Dorrans
•
7K vues
(DEV203) Amazon API Gateway & AWS Lambda to Build Secure APIs
Amazon Web Services
•
17K vues
AWS API Gateway - AJUG August 2018
Yoel Spotts
•
147 vues
En vedette
(11)
SignalR
Troy Miles
•
5.9K vues
«Real Time» Web Applications with SignalR in ASP.NET
Alessandro Giorgetti
•
5.4K vues
SignalR
Slawomir Dorzak
•
1.8K vues
SignalR
William Austin
•
651 vues
Signal R 2015
Mihai Coscodan
•
247 vues
ELEIÇÕES 2012 - ASTORGA: Toninho 31123
Joao Carlos Passari
•
175 vues
Real time web with SignalR
Alessandro Melchiori
•
1.5K vues
Real-time ASP.NET with SignalR
Alexander Konduforov
•
11.7K vues
SignalR for ASP.NET Developers
Shivanand Arur
•
6.9K vues
Anatomy of a Modern Node.js Application Architecture
AppDynamics
•
40K vues
Real Time Data Visualization using asp.net / SignalR + D3.js
Sunny Sharma
•
1.9K vues
Publicité
Similaire à SignalR
(20)
Consul: Service Mesh for Microservices
ArmonDadgar
•
433 vues
Models
Eyal Vardi
•
2.1K vues
Introduction To Dot Net Siddhesh
Siddhesh Bhobe
•
1.4K vues
Asp.net mvc internals & extensibility
Eyal Vardi
•
1.9K vues
introduction to Windows Comunication Foundation
redaxe12
•
2.7K vues
Oop2008 RESTful services with GWT and Apache CXF
Adrian Trenaman
•
1.7K vues
The use of Symfony2 @ Overblog
Xavier Hausherr
•
5K vues
Windows Azure Mobile Services
Sasha Goldshtein
•
1.4K vues
Asp.Net Mvc Internals & Extensibility
Eyal Vardi
•
2K vues
Fiware IoT_IDAS_intro_ul20_v2
FIWARE
•
8.3K vues
Corba model ppt
Saransh Garg
•
1.2K vues
solc-verify: A Modular Verifier for Solidity Smart Contracts
Akos Hajdu
•
185 vues
Java client socket-20070327
Tsu-Fen Han
•
296 vues
OneTeam Media Server
Mickaël Rémond
•
876 vues
Architecture your android_application
Mark Brady
•
2.5K vues
Creating a Java Internet of Things Gateway
Eurotech
•
2.8K vues
Iphone client-server app with Rails backend (v3)
Sujee Maniyam
•
9.1K vues
以Device Shadows與Rules Engine串聯實體世界
Amazon Web Services
•
2.2K vues
Networking and Data Access with Eqela
jobandesther
•
1.7K vues
Prism Navigation
Eyal Vardi
•
3.4K vues
Plus de Eyal Vardi
(20)
Why magic
Eyal Vardi
•
570 vues
Smart Contract
Eyal Vardi
•
574 vues
Rachel's grandmother's recipes
Eyal Vardi
•
786 vues
Performance Optimization In Angular 2
Eyal Vardi
•
1.7K vues
Angular 2 Architecture (Bucharest 26/10/2016)
Eyal Vardi
•
4.1K vues
Angular 2 NgModule
Eyal Vardi
•
1.1K vues
Upgrading from Angular 1.x to Angular 2.x
Eyal Vardi
•
1.4K vues
Angular 2 - Ahead of-time Compilation
Eyal Vardi
•
945 vues
Routing And Navigation
Eyal Vardi
•
596 vues
Angular 2 Architecture
Eyal Vardi
•
6.2K vues
Angular 1.x vs. Angular 2.x
Eyal Vardi
•
6.4K vues
Angular 2.0 Views
Eyal Vardi
•
1.8K vues
Component lifecycle hooks in Angular 2.0
Eyal Vardi
•
3.4K vues
Template syntax in Angular 2.0
Eyal Vardi
•
3.6K vues
Http Communication in Angular 2.0
Eyal Vardi
•
2.8K vues
Angular 2.0 Dependency injection
Eyal Vardi
•
4.3K vues
Angular 2.0 Routing and Navigation
Eyal Vardi
•
2.5K vues
Async & Parallel in JavaScript
Eyal Vardi
•
2.2K vues
Angular 2.0 Pipes
Eyal Vardi
•
1.8K vues
Angular 2.0 forms
Eyal Vardi
•
3.3K vues
Publicité
Dernier
(20)
Mobile Medical Service Project
AdamAnnafi1
•
0 vue
Failure: Gopher Protocol
Onri Jay Benally
•
0 vue
12_AI_Model Life cycle1.pdf
Elan71
•
0 vue
DAI.pptx
AM Shamsuddula
•
0 vue
Level Up Your Property and Investment Management Workflows
AppFolio
•
3 vues
Python para equipos de ciberseguridad
Jose Manuel Ortega Candel
•
3 vues
Audio console
Butterfly education
•
10 vues
Vin secure solutions PPT (1).pdf
vin secure solutions
•
3 vues
Cloud Forensics Tools
Christopher Doman
•
7 vues
Future Managers with New Technology.pptx
Simhadri Bhavana
•
6 vues
Python Datatypes.pptx
M Vishnuvardhan Reddy
•
6 vues
Python Basics.pptx
M Vishnuvardhan Reddy
•
6 vues
The Benefits of Adopting the Lamp Tech Stack: A Comprehensive Guide:
Brain Inventory
•
2 vues
Software development company in Dubai
MaqUAE
•
0 vue
Using Data-Driven Agile Automation to Advance Digital Transformation
Precisely
•
4 vues
On the Cloud? Data Integrity for Insurers in Cloud-Based Platforms
Precisely
•
7 vues
Tunability of Thin Film Tantalum Nitride Grown by Sputtering
Onri Jay Benally
•
0 vue
SEARCH-ENGINE-OPTIMIZATION-SEO-BEGINNERS-TOOLS(1).pdf
GeraldNsofor
•
15 vues
Hong Kong Open Source Conference 2023 - Matter matters! A brief intro to the ...
Amanda Lam
•
0 vue
Implementing cert-manager in K8s
Jose Manuel Ortega Candel
•
7 vues
SignalR
SignalR Eyal
Vardi CEO E4D Solutions LTD Microsoft MVP Visual C# blog: www.eVardi.com
Expert Days 2012
© 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Agenda
SignalR Server Side API SignalR JavaScript API SignalR Client .NET API SignalR Internals SignalR Extensibility © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Sever Side © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
What is SignalR?
SignalR is an asynchronous signaling library for ASP.NET, To help build real-time multi- user web application. SignalR is a complete client- and server-side solution with JS on client and ASP.NET on the back end to create these kinds of applications. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
More Details on
SignalR SignalR is broken up into a few package on NuGet: SignalR - A meta package that brings in SignalR.Server and SignalR.Js (you should install this) SignalR.Server - Server side components needed to build SignalR endpoints SignalR.Js - Javascript client for SignalR SignalR.Client - .NET client for SignalR SignalR.Ninject - Ninject dependeny resolver for SignalR © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Hub Class
Hubs provide a higher level RPC framework over a PersistentConnection. SignalR will handle the binding of complex objects and arrays of objects automatically. [HubName("Chat")] Callable from the client public class Chat : Hub { public string Send(string message) { return message; Deserialization } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Hub API
Hubs are per call, that is, each call from the client to the hub will create a new hub instance. So don't setup static event handlers in hub methods. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Server Calling The
Client To call client event/methods from the server use the Clients property. Parameters passed to the method will be JSON serialized before being sent to the client [HubName("Chat")] public class Chat : Hub { public void Send(string message) { // Call the addMessage method on all clients Clients.addMessage(message); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Calling on Specific
Connections There are some cases where we want to send a message to specific clients or groups. We can use the indexer on the Clients object to specify a connection id. [HubName("Chat")] public class Chat : Hub { public void Send(string message) { Clients[Context.ConnectionId].addMessage(message); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Managing Groups
You can add connections to groups and send messages to particular groups. You may also return Task/Task<T> from a hub if you need to do async work. public class MyHub : Hub, IDisconnect { public Task Join() { return Groups.Add(Context.ConnectionId, "foo"); } public Task Send(string message) { return Clients["foo"].addMessage(message); } public Task Disconnect() { return Clients["foo"].leave(Context.ConnectionId); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
State Between Client
& Server Any state sent from the client can be accessed via the Caller property. You can also set client side state just by setting any property on Caller. [HubName("Chat")] public class Chat : Hub { public void Send(string message) { // Access the id property set from the client. string id = Caller.id; // Set a property on the client state Caller.name = "SignalR"; } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Client Events in
Server Side To detect disconnects when using hubs, implement the IDisconnect interface. To detect connects and reconnects, implement Iconnected. public class Status : Hub, IDisconnect, IConnected { public Task Disconnect() { return Clients.leave(Context.ConnectionId, DateTime.Now.ToString()); } public Task Connect() { return Clients.joined(Context.ConnectionId, DateTime.Now.ToString()); } public Task Reconnect(IEnumerable<string> groups) { return Clients.rejoined(Context.ConnectionId, DateTime.Now.ToString()); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Broadcasting From Outside
of a Hub Sometimes you have some arbitrary code in an application that you want to be able to notify all clients connected when some event occurs. public class Notifier { public static void Say(string message) { var context = GlobalHost.ConnectionManager.GetHubContext<MyHub>(); context.Clients.say(message); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Hub Routing
No need to specify a route for the hub as they are automatically accessible over a special url (/signalr) public class MvcApplication : System.Web.HttpApplication { protected void Application_Start() { RouteTable.Routes.MapHubs("~/signalr2"); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Client Side © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
JavaScript Client
<script src="Scripts/jquery.signalR-0.5.3.min.js" type="text/javascript"></script> <script src="/signalr/hubs" type="text/javascript"></script> <script type="text/javascript"> $(function () { // Proxy created on the fly var chat = $.connection.chat; // Declare a function on the chat hub so the server can invoke it chat.addMessage = function (message) { $('#messages').append('<li>' + message + '</li>'); }; $("#broadcast").click(function () { // Call the chat method on the server chat.send($('#msg').val()); }); // Start the connection $.connection.hub.start(); }); </script> © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
JavaScript API
$.connection.hub The connection for all hubs (url points to /signalr). Returns a connection $.connection.hub.id The client id for the hub connection. $.connection.hub.logging Set to true to enable logging. Default is false $.connection.hub.start() Starts the connection for all hubs. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Exposing Methods For
The Server The JavaScript client can declare methods that the server can invoke. myHub.{method} = callback Method - name of the client side method. Callback - A function to execute when the server invokes the method. NOTE: if you misspell you will NOT get any warning or notifications even when logging is enabled. NOTE: Unlike the name change in myHub, the function names here at the same as you call in Server code. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Invoking methods on
the server The proxy will generate methods on each hub for the associated server methods. Returns jQuery deferred. NOTE: Method names will be camel cased similarly to hub names. myHub.someMethod() .done(function(result) {}) .fail(function(error) {}); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Round-Tripping State
To set state on the hub. Just assign values to properties on the hub object. myHub.name = “E4D” Whenever a call to the hub the state will be sent to the server. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Cross Domain Support
You can talk to SignalR servers either using websockets, cors enabled longpolling (not supported by all browsers) or jsonp longpolling. Cross domain urls are auto detected. We'll use xhr by default if the client (your browser) supports it. $.connection.hub.url = 'http://localhost:8081/signalr'; $.connection.hub.start(); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Cross Domain Support
(JSONP) Cross domain fall back to jsonp longpolling. To use jsonp longpolling, you can specify that option explicitly: $.connection.hub.url = 'http://localhost:8081/signalr'; $.connection.hub.start({ jsonp: true }); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
$.connection.hub.logging = true;
var myHub = $.connection.myHub; myHub.someState = "SomeValue"; function connectionReady() { alert("Done calling first hub serverside-function"); }; myHub.SomeClientFunction = function () { alert("serverside called 'Clients.SomeClientFunction()'"); }; $.connection.hub.error(function () { alert("An error occured"); }); $.connection.hub.start() .done(function () { myHub.SomeFunction(SomeParam) //e.g. a login or init .done(connectionReady); }) .fail(function () { alert("Could not Connect!"); }); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Client JavaScript © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
.Net Client
// Connect to the service var hubConnection = new HubConnection("http://localhost/mysite"); // Create a proxy to the chat service var chat = hubConnection.CreateProxy("chat"); // Print the message when it comes in chat.On("addMessage", message => Console.WriteLine(message)); // Start the connection hubConnection.Start().Wait(); string line = null; while ((line = Console.ReadLine()) != null) { // Send a message to the server chat.Invoke("Send", line).Wait(); } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
SignalR Internals © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Default Start Point
The AspNetBootstrapper class initializes the Asp.Net hosting pipeline with HubDispatcher [assembly: PreApplicationStartMethod(typeof(AspNetBootstrapper), "Initialize")] namespace SignalR.Hosting.AspNet { public static class AspNetBootstrapper { ... // Initializes the ASP.NET host and sets up the default hub route (~/signalr). public static void Initialize() { Add Route ... RouteTable.Routes.MapHubs(); ... } private static void OnAppDomainShutdown() { ... } } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
MapHubs Extension Methods
The MapHubs does two things : Register the AspNetAssemblyLocator Build the route class for SignalR var locator = new Lazy<IAssemblyLocator>(() => new AspNetAssemblyLocator()); resolver.Register(typeof(IAssemblyLocator), () => locator.Value); var route = new Route(routeUrl, new HubDispatcherRouteHandler(url, resolver)); routeUrl = "~/signalr /{*operation}" © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
HubDispatcherRouteHandler
public IHttpHandler GetHttpHandler(RequestContext requestContext) { var dispatcher = new HubDispatcher(_url); return new AspNetHandler(_resolver, dispatcher); } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Persistent Connection © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
HubDispatcher
public override Task ProcessRequestAsync(HostContext context) { // Generate the proxy if (context.Request.Url.LocalPath.EndsWith("/hubs",StringComparison.OrdinalIgnoreCase)) { context.Response.ContentType = "application/x-javascript"; return context.Response.EndAsync(_proxyGenerator.GenerateProxy(_url)); } ... return base.ProcessRequestAsync(context); } protected override Task OnReceivedAsync(IRequest req, string connId, string data) { ... // 1. Create the hub ... // 2. Resolve the method ... // 3. Resolving the state ... // 4. Invoke the method ... } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
SignalR Extensibility © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Low Level Connection
You can add your own route RouteTable.Routes.MapConnection<MyConnection>("echo", "echo/{*operation}"); public class MyConnection : PersistentConnection { protected override Task OnReceivedAsync(string clientId, string data) { // Broadcast data to all clients return global::SignalR.Connection.Broadcast(data); } } © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
SignalR Extensibility
SignalR is built with dependency injection in mind. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Configuring SignalR
ConnectionTimeout The amount of time to leave a connection open before timing out. Default is 110 seconds. DisconnectTimeout The amount of time to wait after a connection goes away before raising the disconnect event. Default is 20 seconds. HeartBeatInterval The interval for checking the state of a connection. Default is 10 seconds. KeepAlive The amount of time to wait before sending a keep alive packet over an idle connection. Set to null to disable keep alive. This is set to 30 seconds by default. When this is on, the ConnectionTimeout will have no effect. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Replacing individual components
You can replace individual parts of SignalR without replacing the DependencyResolver by calling. GlobalHost .DependencyResolver .Register( typeof(IConnectionIdFactory), () => new CustomIdFactory() ); © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Replaceable Components
The following lists the pluggable interfaces in SignalR. Interfaces Description IMessageBus Message bus. IConnectionIdGenerator Generates connection ids. IAssemblyLocator Locates assemblies to find hubs in. IJavaScriptProxyGenerator Generates the client proxy for hubs. IJavaScriptMinifier Allows the dynamic javascript proxy to be minified. IJsonSerializer Used to serialize and deserialze outgoing/incoming data. © 2010 E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Server Side © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Client Side © 2010
E4D LTD. All rights reserved. Tel: 054-5-767-300, Email: Eyal@E4D.co.il
Publicité