Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Think in real-time with Xamarin and Azure Signa...

Think in real-time with Xamarin and Azure SignalR Service

Andrea Ceroni

June 20, 2019
Tweet

More Decks by Andrea Ceroni

Other Decks in Programming

Transcript

  1. NEXT CONFERENCES CODEMOTION MADRID: September 24-25 CODEMOTION MILAN: October 24-25

    CODEMOTION BERLIN: November 12-13 CODEMOTION AMSTERDAM 2020
  2. Use SignalR Service Scale an ASP.NET Core SignalR App integrate

    with ASP.NET Core (based on this) allows to scale-out the number of connections Build serveless real-time apps using Azure Functions (v2) bindings it is possible to "react" to a whole series of events (storage, queue, http trigger...) Send messages from server to client with the REST API integrate with other apps that they can call the API and "push" informations to the clients tips...
  3. Concepts Transports based on the server and client capabilities SignalR

    choose the best transport among WebSocket, Server-Sent Events e Long Polling Hubs an hub is a high level pipeline which allows clients and servers to call each other, passing "strongly-typed" parameters to the methods. The message contains the name of the method to be invoked and the related parameters. Therefore exists a real "contract" between client and server
  4. With our without ASP.NET Core SignalR Azure SignalR Service Xamarin

    ASP.NET Core SignalR Server Hub Web App Console App Azure SignalR Service Server Endpoint Client Endpoint Xamarin Web App Console App What you want REST API
  5. ASP.NET Core SignalR vs SignalR Service Persistent Connection Client App

    Server Azure SignalR Service Client App Server Persistent Connection Persistent Connection Negotiate
  6. Different connections Server connections Persistent websocket connetcions are opened between

    SignalR Service and SignalR Server (5 by default), used for two-way communications with clients Client connections Clients are connected directly to SignalR Service, url and access token are resolved by the endpoint "negotiate" Data transmit 1 to 1 mapping between client connection and relative server connection that takes charge of it. Therefore SignalR Service acts as a transport layer between server and clients, completely managing the connections (scalability)
  7. Server-less Architecture with Azure Functions Client Azure SignalR Service Persistent

    Connection Azure Functions negotiate Negotiate broadcast
  8. [FunctionName(" Question")] public async Task<IActionResult> Question( [HttpTrigger(AuthorizationLevel.Anonymous, "post")] Question question,

    [SignalR(HubName = "Q&A")] IAsyncCollector<SignalRMessage> answers) { var answer = iKnowTheAnswer J ? question.GetAnswer() : ... L ... return await answers.AddAsync(new SignalRMessage { Target = " Answer", Arguments = new [ ] { answer } }); }