SlideShare a Scribd company logo
1 of 18
ASP.NET Core SignalR &
Xamarin.Forms
Connect ASP.NET Core SignalR service via .NET Standard 2.0 C#
client library in Xamarin.Forms
ASP.NET Core SignalR
• A re-designed SignalR(http://signalr.net/) library for ASP.NET
Core 2.1 to provide real-time communication:
http://github.com/aspnet/signalr
• Not compatible with old ASP.NET SignalR.
• Existing Application that use ASP.NET SignalR or ASP.NET Core
SignalR:
• Office 365 real-time document co-authoring: http://bit.ly/2KIZjrb
• Visual Studio Live Share: http://bit.ly/2Nl8Aak
ASP.NET Core SignalR Features
• Multiple transport mechanism:
• Websocket: http://bit.ly/2MLVwtL
• Server-Send event: http://bit.ly/2KuvkXW
• Long Polling: http://bit.ly/2lOvg6t
• Hub concepts for client & server communication:
• Hub protocols: text based JSON & binary based MessagePack (
http://msgpack.org/ )
• Support 3 RPC style:
1. Server RPC call
2. Server Streaming RPC call
3. Server Call Client defined function
ASP.NET Core SignalR Features
• Hub Protocol spec is opened:
http://github.com/aspnet/SignalR/blob/master/specs/HubProtocol.m
d
• Provide many language implementation of client library:
• JavaScript: http://www.npmjs.com/package/@aspnet/signalr
• C#: http://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client/
• C++ & Java Client are under development and will release stable version with
ASP.NET Core 2.2 timeline.
• 3rd Party:
• Swift : http://github.com/moozzyk/SignalR-Client-Swift
• RxJs enabled Js client: http:///www.npmjs.com/package/@ssv/signalr-client
ASP.NET Core SignalR Features
• Hub support ASP.NET Core Authentication mechanism
• Cookie
• JWT Auth Token
• Service instance can be scale-out using Redis on-premises,
using Azure SignalR Service(https://aka.ms/signalr_service ) in
cloud.
• Note: ASP.NET SignalR can scale-out via Azure Service Bus, but
there’s no plan for ASP.NET Core SignalR right now:
https://github.com/aspnet/SignalR/issues/1676
Xamarin & ASP.NET Core SignalR
• Using ASP.NET Core SignalR technology, we can build a cross
platform/device broadcasting system via Xamarin.
• Demo code:
http://bit.ly/2KHv57D
Xamarin.Forms as Core SignalR client
Using following Nuget Package in Xamarin.Forms project:
• Microsoft.AspNetCore.SignalR.Client:
https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client/
• Microsoft.Extensions.Logging.Console:
(for iOS & Android logging)
https://www.nuget.org/packages/Microsoft.Extensions.Logging.Console/
• Microsoft.Extensions.Logging.Debug:
(for UWP logging)
https://www.nuget.org/packages/Microsoft.Extensions.Logging.Debug/
• System.Threading.Channels:
(for invoke Server Streaming RPC call)
https://www.nuget.org/packages/System.Threading.Channels/
Xamarin.Forms as Core SignalR client
• Hub: a connection joint that client & sever can call their defined
methods mutually.
Server
Client #1
Client #2
Client #3
Hub
Xamarin.Forms as Core SignalR client
• On Client side, use “HubConnection(http://bit.ly/2tRduE6)” to
access the Server Method defined in Hub.
• To create HubConnection object, using
“HubConnectionBuilder(http://bit.ly/2MLLGYC)” to create.
• HubConnectionBuilder has many Fluent-API style extension
method to configure it. (ASP.NET Core configuration style)
Xamarin.Forms as Core SignalR client
• This kind of “Code as Configuration” coding style is very
modifiable based on demand, and can be refactored to a clear
style using Action Delegate:
http://www.tutorialsteacher.com/csharp/csharp-action-delegate
Xamarin.Forms as Core SignalR client
• Once HubConneciton instance is created, call StartAsync() to
connect to remote ASP.NET Core SignalR server, call
StopAsync() or DisposeAsync() to tear down connection,
HubConnection object cannot be re-used, must create it every
time when starting a new connection.
Xamarin.Forms as Core SignalR client
• Server RPC call : (http://bit.ly/2KKDXN8)
• Use HubConnectionExtensions.InvokeAsync<TResult>()
extension method(http://bit.ly/2MOpy03 ) to get RPC call result.
Xamarin.Forms as Core SignalR client
• Server Streaming RPC call: http://bit.ly/2tQLbp4
• Use
HubConnectionExtensions.StreamAsChannelAsync<TResult>()
extension method (http://bit.ly/2zfC1bc),
• Which needs additional New Type called
“ChannelReader(http://bit.ly/2MJARXi)” from .NET Core runtime, that
is not documented in official docs yet.
Channel(http://bit.ly/2KJAkXG) is a kind of Data Queue that
mimics Go’s “Buffered Channel(http://bit.ly/2IRo56K)” concept:
https://github.com/stephentoub/corefxlab/blob/master/src/Syst
em.Threading.Tasks.Channels/README.md
Xamarin.Forms as Core SignalR client
• Server Streaming RPC call can be cancelled from client via Set
Cancellation token parameter in
HubConnectionExtensions.StreamAsChannelAsync<TResult>()
Xamarin.Forms as Core SignalR client
• Server Call Client defined function: (http://bit.ly/2lT4cDf)
Register client function using HubConnection.On() or
HubConnectionExtensions.On(http://bit.ly/2IQ0Auw) API:
Other Notes
Xamarin Client need to use latest preview of Visual Studio 2017 15.8
preview 3 or Visual Studio for Mac 7.6 preview 3:
https://github.com/aspnet/Announcements/issues/305
• UWP on Windows 10 Mobile OS is not support since .NET Standard
2.0 support for Windows 10 UWP comes in 2017 Fall Creators
Update.
• UWP logging has to use AddDebug(), not AddConsole().
• JWT Authentication is configured on HubConnectionBuilder’s
WithUrl() extension method:
https://github.com/aspnet/SignalR/blob/948ebf34ece11918804f443b65c6a053dfc
8f35c/samples/JwtClientSample/Program.cs#L38
• Local debugging & testing can use ngrok(http://ngrok.com) for real
device connection.
Resources
• Code Magazine 2018 Jul/Aug issue:
http://www.codemag.com/Magazine/Issue/JulAug18
• Official doc: http://docs.microsoft.com/en-
us/aspnet/core/signalr/dotnet-client
• ASP.NET Core SignalR source code repo:
http://github.com/aspnet/signalr
• ASP.NET Core sample code repo:
http://github.com/aspnet/SignalR-samples
• Build 2018 Introduction Video:
https://channel9.msdn.com/Events/Build/2018/BRK2147

More Related Content

What's hot

Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin KnaufWebinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin KnaufVerverica
 
Cortex: Prometheus as a Service, One Year On
Cortex: Prometheus as a Service, One Year OnCortex: Prometheus as a Service, One Year On
Cortex: Prometheus as a Service, One Year OnKausal
 
Practical tips and tricks for Apache Kafka messages integration | Francesco T...
Practical tips and tricks for Apache Kafka messages integration | Francesco T...Practical tips and tricks for Apache Kafka messages integration | Francesco T...
Practical tips and tricks for Apache Kafka messages integration | Francesco T...HostedbyConfluent
 
Making clouds: turning opennebula into a product
Making clouds: turning opennebula into a productMaking clouds: turning opennebula into a product
Making clouds: turning opennebula into a productCarlo Daffara
 
20170701 kkbox的團隊協作方式
20170701 kkbox的團隊協作方式20170701 kkbox的團隊協作方式
20170701 kkbox的團隊協作方式CQD
 
Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...
Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...
Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...Flink Forward
 
Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Ver...
Towards Flink 2.0:  Unified Batch & Stream Processing - Aljoscha Krettek, Ver...Towards Flink 2.0:  Unified Batch & Stream Processing - Aljoscha Krettek, Ver...
Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Ver...Flink Forward
 
Windows Azure PowerShell Cmdlets
Windows Azure PowerShell CmdletsWindows Azure PowerShell Cmdlets
Windows Azure PowerShell CmdletsPavel Revenkov
 
NGINX_conf_2016_talk
NGINX_conf_2016_talkNGINX_conf_2016_talk
NGINX_conf_2016_talkkunalvjti
 
Kubernetes + Operator + PaaSTA = Flink @ Yelp - Antonio Verardi, Yelp
Kubernetes + Operator + PaaSTA = Flink @ Yelp -  Antonio Verardi, YelpKubernetes + Operator + PaaSTA = Flink @ Yelp -  Antonio Verardi, Yelp
Kubernetes + Operator + PaaSTA = Flink @ Yelp - Antonio Verardi, YelpFlink Forward
 
CNTUG x SDN Meetup #33 Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
CNTUG x SDN Meetup #33  Talk 1: 從 Cilium 認識 cgroup ebpf - RuianCNTUG x SDN Meetup #33  Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
CNTUG x SDN Meetup #33 Talk 1: 從 Cilium 認識 cgroup ebpf - RuianHanLing Shen
 
Scalatra scala meetup
Scalatra scala meetupScalatra scala meetup
Scalatra scala meetupTomasz Lelek
 
The Conf 2019 - Elixir - Emerson Macedo
The Conf 2019 - Elixir - Emerson MacedoThe Conf 2019 - Elixir - Emerson Macedo
The Conf 2019 - Elixir - Emerson MacedoEmerson Macedo
 
Monitoring on Kubernetes using prometheus
Monitoring on Kubernetes using prometheusMonitoring on Kubernetes using prometheus
Monitoring on Kubernetes using prometheusChandresh Pancholi
 
Flink Connector Development Tips & Tricks
Flink Connector Development Tips & TricksFlink Connector Development Tips & Tricks
Flink Connector Development Tips & TricksEron Wright
 
Getting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and GrafanaGetting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and GrafanaSyah Dwi Prihatmoko
 
Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019Thomas Weise
 
A new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days MontpellierA new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days MontpellierLuca Lusso
 
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...Flink Forward
 

What's hot (20)

Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin KnaufWebinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
Webinar: 99 Ways to Enrich Streaming Data with Apache Flink - Konstantin Knauf
 
Cortex: Prometheus as a Service, One Year On
Cortex: Prometheus as a Service, One Year OnCortex: Prometheus as a Service, One Year On
Cortex: Prometheus as a Service, One Year On
 
Practical tips and tricks for Apache Kafka messages integration | Francesco T...
Practical tips and tricks for Apache Kafka messages integration | Francesco T...Practical tips and tricks for Apache Kafka messages integration | Francesco T...
Practical tips and tricks for Apache Kafka messages integration | Francesco T...
 
Making clouds: turning opennebula into a product
Making clouds: turning opennebula into a productMaking clouds: turning opennebula into a product
Making clouds: turning opennebula into a product
 
20170701 kkbox的團隊協作方式
20170701 kkbox的團隊協作方式20170701 kkbox的團隊協作方式
20170701 kkbox的團隊協作方式
 
Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...
Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...
Flink Forward San Francisco 2019: Building production Flink jobs with Airstre...
 
Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Ver...
Towards Flink 2.0:  Unified Batch & Stream Processing - Aljoscha Krettek, Ver...Towards Flink 2.0:  Unified Batch & Stream Processing - Aljoscha Krettek, Ver...
Towards Flink 2.0: Unified Batch & Stream Processing - Aljoscha Krettek, Ver...
 
Windows Azure PowerShell Cmdlets
Windows Azure PowerShell CmdletsWindows Azure PowerShell Cmdlets
Windows Azure PowerShell Cmdlets
 
NGINX_conf_2016_talk
NGINX_conf_2016_talkNGINX_conf_2016_talk
NGINX_conf_2016_talk
 
Kubernetes + Operator + PaaSTA = Flink @ Yelp - Antonio Verardi, Yelp
Kubernetes + Operator + PaaSTA = Flink @ Yelp -  Antonio Verardi, YelpKubernetes + Operator + PaaSTA = Flink @ Yelp -  Antonio Verardi, Yelp
Kubernetes + Operator + PaaSTA = Flink @ Yelp - Antonio Verardi, Yelp
 
CNTUG x SDN Meetup #33 Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
CNTUG x SDN Meetup #33  Talk 1: 從 Cilium 認識 cgroup ebpf - RuianCNTUG x SDN Meetup #33  Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
CNTUG x SDN Meetup #33 Talk 1: 從 Cilium 認識 cgroup ebpf - Ruian
 
Scalatra scala meetup
Scalatra scala meetupScalatra scala meetup
Scalatra scala meetup
 
The Conf 2019 - Elixir - Emerson Macedo
The Conf 2019 - Elixir - Emerson MacedoThe Conf 2019 - Elixir - Emerson Macedo
The Conf 2019 - Elixir - Emerson Macedo
 
Monitoring on Kubernetes using prometheus
Monitoring on Kubernetes using prometheusMonitoring on Kubernetes using prometheus
Monitoring on Kubernetes using prometheus
 
Flink Connector Development Tips & Tricks
Flink Connector Development Tips & TricksFlink Connector Development Tips & Tricks
Flink Connector Development Tips & Tricks
 
Getting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and GrafanaGetting Started Monitoring with Prometheus and Grafana
Getting Started Monitoring with Prometheus and Grafana
 
Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019Streaming your Lyft Ride Prices - Flink Forward SF 2019
Streaming your Lyft Ride Prices - Flink Forward SF 2019
 
A new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days MontpellierA new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
A new tool for measuring performance in Drupal 8 - Drupal Dev Days Montpellier
 
gogul
gogulgogul
gogul
 
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
 

Similar to Xamarin Form using ASP.NET Core SignalR client

.NET Core Today and Tomorrow
.NET Core Today and Tomorrow.NET Core Today and Tomorrow
.NET Core Today and TomorrowJon Galloway
 
Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)Deepak Gupta
 
ASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveJon Galloway
 
Fancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRFancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRVladimir Georgiev
 
Asp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationAsp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationabhishek singh
 
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.jsAsynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.jsChristian Heindel
 
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel AppelBuilding Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel.NET Conf UY
 
SignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsSignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsEugene Zharkov
 
What you need to know about .NET Core 3.0 and beyond
What you need to know about .NET Core 3.0 and beyondWhat you need to know about .NET Core 3.0 and beyond
What you need to know about .NET Core 3.0 and beyondJon Galloway
 
Building high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache ThriftBuilding high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache ThriftRX-M Enterprises LLC
 
IoT with SignalR & .NET Gadgeteer - NetMF@Work
IoT with SignalR & .NET Gadgeteer - NetMF@WorkIoT with SignalR & .NET Gadgeteer - NetMF@Work
IoT with SignalR & .NET Gadgeteer - NetMF@WorkMirco Vanini
 
Hyperledger Composer architecture
Hyperledger Composer architectureHyperledger Composer architecture
Hyperledger Composer architectureSimon Stone
 
44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw
44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw
44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw44CON
 
SignalR Dublin ALT.NET
SignalR Dublin ALT.NETSignalR Dublin ALT.NET
SignalR Dublin ALT.NETDorin Manoli
 
Stream Processing with Apache Kafka and .NET
Stream Processing with Apache Kafka and .NETStream Processing with Apache Kafka and .NET
Stream Processing with Apache Kafka and .NETconfluent
 
.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?Christian Nagel
 
What's New in .Net 4.5
What's New in .Net 4.5What's New in .Net 4.5
What's New in .Net 4.5Malam Team
 
.NET & C# Updates Fall 2019
.NET & C# Updates Fall 2019.NET & C# Updates Fall 2019
.NET & C# Updates Fall 2019Marco Parenzan
 

Similar to Xamarin Form using ASP.NET Core SignalR client (20)

.NET Core Today and Tomorrow
.NET Core Today and Tomorrow.NET Core Today and Tomorrow
.NET Core Today and Tomorrow
 
Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)Real time Communication with Signalr (Android Client)
Real time Communication with Signalr (Android Client)
 
ASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep DiveASP.NET Core 3.0 Deep Dive
ASP.NET Core 3.0 Deep Dive
 
Introduction to SignalR
Introduction to SignalRIntroduction to SignalR
Introduction to SignalR
 
Fancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalRFancy Features in Asp.Net Core SignalR
Fancy Features in Asp.Net Core SignalR
 
Asp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentationAsp.net and .Net Framework ppt presentation
Asp.net and .Net Framework ppt presentation
 
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.jsAsynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
Asynchrone Echtzeitanwendungen für SharePoint mit SignalR und knockout.js
 
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel AppelBuilding Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel
Building Real Time Applications with ASP.NET SignalR 2.0 by Rachel Appel
 
SignalR: Add real-time to your applications
SignalR: Add real-time to your applicationsSignalR: Add real-time to your applications
SignalR: Add real-time to your applications
 
What you need to know about .NET Core 3.0 and beyond
What you need to know about .NET Core 3.0 and beyondWhat you need to know about .NET Core 3.0 and beyond
What you need to know about .NET Core 3.0 and beyond
 
Building high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache ThriftBuilding high performance microservices in finance with Apache Thrift
Building high performance microservices in finance with Apache Thrift
 
IoT with SignalR & .NET Gadgeteer - NetMF@Work
IoT with SignalR & .NET Gadgeteer - NetMF@WorkIoT with SignalR & .NET Gadgeteer - NetMF@Work
IoT with SignalR & .NET Gadgeteer - NetMF@Work
 
Hyperledger Composer architecture
Hyperledger Composer architectureHyperledger Composer architecture
Hyperledger Composer architecture
 
44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw
44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw
44CON 2014 - Binary Protocol Analysis with CANAPE, James Forshaw
 
SignalR Dublin ALT.NET
SignalR Dublin ALT.NETSignalR Dublin ALT.NET
SignalR Dublin ALT.NET
 
Stream Processing with Apache Kafka and .NET
Stream Processing with Apache Kafka and .NETStream Processing with Apache Kafka and .NET
Stream Processing with Apache Kafka and .NET
 
.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?.NET Core 3.0 - What's new?
.NET Core 3.0 - What's new?
 
What's New in .Net 4.5
What's New in .Net 4.5What's New in .Net 4.5
What's New in .Net 4.5
 
.NET & C# Updates Fall 2019
.NET & C# Updates Fall 2019.NET & C# Updates Fall 2019
.NET & C# Updates Fall 2019
 
Signal R 2015
Signal R 2015Signal R 2015
Signal R 2015
 

More from Chen Yu Pao

HoloLens 2的 MR(Mixed Reality)開發入門
HoloLens 2的 MR(Mixed Reality)開發入門HoloLens 2的 MR(Mixed Reality)開發入門
HoloLens 2的 MR(Mixed Reality)開發入門Chen Yu Pao
 
SkiaSharp on Xamarin Forms
SkiaSharp on Xamarin FormsSkiaSharp on Xamarin Forms
SkiaSharp on Xamarin FormsChen Yu Pao
 
ReactiveUI Xamarin.Forms
ReactiveUI Xamarin.FormsReactiveUI Xamarin.Forms
ReactiveUI Xamarin.FormsChen Yu Pao
 
WebSocket on client & server using websocket-sharp & ASP.NET Core
WebSocket on client & server using websocket-sharp & ASP.NET CoreWebSocket on client & server using websocket-sharp & ASP.NET Core
WebSocket on client & server using websocket-sharp & ASP.NET CoreChen Yu Pao
 
使用JetBrains Rider開發Xamarin Forms
使用JetBrains Rider開發Xamarin Forms使用JetBrains Rider開發Xamarin Forms
使用JetBrains Rider開發Xamarin FormsChen Yu Pao
 
Xamarin ARKit Introduction 01
Xamarin ARKit Introduction 01Xamarin ARKit Introduction 01
Xamarin ARKit Introduction 01Chen Yu Pao
 
Xamarin native forms
Xamarin native formsXamarin native forms
Xamarin native formsChen Yu Pao
 
Xamarin的Azure後端懶人包
Xamarin的Azure後端懶人包Xamarin的Azure後端懶人包
Xamarin的Azure後端懶人包Chen Yu Pao
 
Proto actor 串接 Go 與 C# 簡易上手
Proto actor 串接 Go 與 C# 簡易上手Proto actor 串接 Go 與 C# 簡易上手
Proto actor 串接 Go 與 C# 簡易上手Chen Yu Pao
 

More from Chen Yu Pao (9)

HoloLens 2的 MR(Mixed Reality)開發入門
HoloLens 2的 MR(Mixed Reality)開發入門HoloLens 2的 MR(Mixed Reality)開發入門
HoloLens 2的 MR(Mixed Reality)開發入門
 
SkiaSharp on Xamarin Forms
SkiaSharp on Xamarin FormsSkiaSharp on Xamarin Forms
SkiaSharp on Xamarin Forms
 
ReactiveUI Xamarin.Forms
ReactiveUI Xamarin.FormsReactiveUI Xamarin.Forms
ReactiveUI Xamarin.Forms
 
WebSocket on client & server using websocket-sharp & ASP.NET Core
WebSocket on client & server using websocket-sharp & ASP.NET CoreWebSocket on client & server using websocket-sharp & ASP.NET Core
WebSocket on client & server using websocket-sharp & ASP.NET Core
 
使用JetBrains Rider開發Xamarin Forms
使用JetBrains Rider開發Xamarin Forms使用JetBrains Rider開發Xamarin Forms
使用JetBrains Rider開發Xamarin Forms
 
Xamarin ARKit Introduction 01
Xamarin ARKit Introduction 01Xamarin ARKit Introduction 01
Xamarin ARKit Introduction 01
 
Xamarin native forms
Xamarin native formsXamarin native forms
Xamarin native forms
 
Xamarin的Azure後端懶人包
Xamarin的Azure後端懶人包Xamarin的Azure後端懶人包
Xamarin的Azure後端懶人包
 
Proto actor 串接 Go 與 C# 簡易上手
Proto actor 串接 Go 與 C# 簡易上手Proto actor 串接 Go 與 C# 簡易上手
Proto actor 串接 Go 與 C# 簡易上手
 

Recently uploaded

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfPower Karaoke
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 

Recently uploaded (20)

The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
The Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdfThe Evolution of Karaoke From Analog to App.pdf
The Evolution of Karaoke From Analog to App.pdf
 
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 

Xamarin Form using ASP.NET Core SignalR client

  • 1. ASP.NET Core SignalR & Xamarin.Forms Connect ASP.NET Core SignalR service via .NET Standard 2.0 C# client library in Xamarin.Forms
  • 2. ASP.NET Core SignalR • A re-designed SignalR(http://signalr.net/) library for ASP.NET Core 2.1 to provide real-time communication: http://github.com/aspnet/signalr • Not compatible with old ASP.NET SignalR. • Existing Application that use ASP.NET SignalR or ASP.NET Core SignalR: • Office 365 real-time document co-authoring: http://bit.ly/2KIZjrb • Visual Studio Live Share: http://bit.ly/2Nl8Aak
  • 3. ASP.NET Core SignalR Features • Multiple transport mechanism: • Websocket: http://bit.ly/2MLVwtL • Server-Send event: http://bit.ly/2KuvkXW • Long Polling: http://bit.ly/2lOvg6t • Hub concepts for client & server communication: • Hub protocols: text based JSON & binary based MessagePack ( http://msgpack.org/ ) • Support 3 RPC style: 1. Server RPC call 2. Server Streaming RPC call 3. Server Call Client defined function
  • 4. ASP.NET Core SignalR Features • Hub Protocol spec is opened: http://github.com/aspnet/SignalR/blob/master/specs/HubProtocol.m d • Provide many language implementation of client library: • JavaScript: http://www.npmjs.com/package/@aspnet/signalr • C#: http://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client/ • C++ & Java Client are under development and will release stable version with ASP.NET Core 2.2 timeline. • 3rd Party: • Swift : http://github.com/moozzyk/SignalR-Client-Swift • RxJs enabled Js client: http:///www.npmjs.com/package/@ssv/signalr-client
  • 5. ASP.NET Core SignalR Features • Hub support ASP.NET Core Authentication mechanism • Cookie • JWT Auth Token • Service instance can be scale-out using Redis on-premises, using Azure SignalR Service(https://aka.ms/signalr_service ) in cloud. • Note: ASP.NET SignalR can scale-out via Azure Service Bus, but there’s no plan for ASP.NET Core SignalR right now: https://github.com/aspnet/SignalR/issues/1676
  • 6. Xamarin & ASP.NET Core SignalR • Using ASP.NET Core SignalR technology, we can build a cross platform/device broadcasting system via Xamarin. • Demo code: http://bit.ly/2KHv57D
  • 7. Xamarin.Forms as Core SignalR client Using following Nuget Package in Xamarin.Forms project: • Microsoft.AspNetCore.SignalR.Client: https://www.nuget.org/packages/Microsoft.AspNetCore.SignalR.Client/ • Microsoft.Extensions.Logging.Console: (for iOS & Android logging) https://www.nuget.org/packages/Microsoft.Extensions.Logging.Console/ • Microsoft.Extensions.Logging.Debug: (for UWP logging) https://www.nuget.org/packages/Microsoft.Extensions.Logging.Debug/ • System.Threading.Channels: (for invoke Server Streaming RPC call) https://www.nuget.org/packages/System.Threading.Channels/
  • 8. Xamarin.Forms as Core SignalR client • Hub: a connection joint that client & sever can call their defined methods mutually. Server Client #1 Client #2 Client #3 Hub
  • 9. Xamarin.Forms as Core SignalR client • On Client side, use “HubConnection(http://bit.ly/2tRduE6)” to access the Server Method defined in Hub. • To create HubConnection object, using “HubConnectionBuilder(http://bit.ly/2MLLGYC)” to create. • HubConnectionBuilder has many Fluent-API style extension method to configure it. (ASP.NET Core configuration style)
  • 10.
  • 11. Xamarin.Forms as Core SignalR client • This kind of “Code as Configuration” coding style is very modifiable based on demand, and can be refactored to a clear style using Action Delegate: http://www.tutorialsteacher.com/csharp/csharp-action-delegate
  • 12. Xamarin.Forms as Core SignalR client • Once HubConneciton instance is created, call StartAsync() to connect to remote ASP.NET Core SignalR server, call StopAsync() or DisposeAsync() to tear down connection, HubConnection object cannot be re-used, must create it every time when starting a new connection.
  • 13. Xamarin.Forms as Core SignalR client • Server RPC call : (http://bit.ly/2KKDXN8) • Use HubConnectionExtensions.InvokeAsync<TResult>() extension method(http://bit.ly/2MOpy03 ) to get RPC call result.
  • 14. Xamarin.Forms as Core SignalR client • Server Streaming RPC call: http://bit.ly/2tQLbp4 • Use HubConnectionExtensions.StreamAsChannelAsync<TResult>() extension method (http://bit.ly/2zfC1bc), • Which needs additional New Type called “ChannelReader(http://bit.ly/2MJARXi)” from .NET Core runtime, that is not documented in official docs yet. Channel(http://bit.ly/2KJAkXG) is a kind of Data Queue that mimics Go’s “Buffered Channel(http://bit.ly/2IRo56K)” concept: https://github.com/stephentoub/corefxlab/blob/master/src/Syst em.Threading.Tasks.Channels/README.md
  • 15. Xamarin.Forms as Core SignalR client • Server Streaming RPC call can be cancelled from client via Set Cancellation token parameter in HubConnectionExtensions.StreamAsChannelAsync<TResult>()
  • 16. Xamarin.Forms as Core SignalR client • Server Call Client defined function: (http://bit.ly/2lT4cDf) Register client function using HubConnection.On() or HubConnectionExtensions.On(http://bit.ly/2IQ0Auw) API:
  • 17. Other Notes Xamarin Client need to use latest preview of Visual Studio 2017 15.8 preview 3 or Visual Studio for Mac 7.6 preview 3: https://github.com/aspnet/Announcements/issues/305 • UWP on Windows 10 Mobile OS is not support since .NET Standard 2.0 support for Windows 10 UWP comes in 2017 Fall Creators Update. • UWP logging has to use AddDebug(), not AddConsole(). • JWT Authentication is configured on HubConnectionBuilder’s WithUrl() extension method: https://github.com/aspnet/SignalR/blob/948ebf34ece11918804f443b65c6a053dfc 8f35c/samples/JwtClientSample/Program.cs#L38 • Local debugging & testing can use ngrok(http://ngrok.com) for real device connection.
  • 18. Resources • Code Magazine 2018 Jul/Aug issue: http://www.codemag.com/Magazine/Issue/JulAug18 • Official doc: http://docs.microsoft.com/en- us/aspnet/core/signalr/dotnet-client • ASP.NET Core SignalR source code repo: http://github.com/aspnet/signalr • ASP.NET Core sample code repo: http://github.com/aspnet/SignalR-samples • Build 2018 Introduction Video: https://channel9.msdn.com/Events/Build/2018/BRK2147