Azure SignaIR the data from the server to the client in real-time push Web and mobile browsers, desktop applications, mobile applications, etc.

Other techniques Websocket / server send events (SSE) / long-polling, etc.: conventional push technology.

SignaIR there is a long history, is the most common .NET platform push technology, and now this technology has to Paas form line to the Azure China's eastern region, and supports C # / Java / JavaScript / Python and other languages.

Azure SignalR service has been used in a variety of industries, suitable for any type of application requires real-time content updates. The following are some examples for using Azure SignalR services:

 

  • High frequency data update: games, voting, polling, auction.

  • Dashboards and monitoring: Corporate dashboards, financial market data, real-time sales updates, leaderboards and multiplayer games IoT monitoring.

  • Chat: Real-time chat rooms, chat robot, online customer support, real-time shop assistant, messenger, in-game chat, and so on.

  • Real-Time Location Map: logistics tracking, delivery status tracking, shipping status updates, GPS applications.

  • Real-time targeted advertising: personalized advertising and real-time push packages, interactive advertising.

  • Collaborative Applications: joint work, team meetings and whiteboard application software.

  • Push Notification: social networks, email, games, travel notice.

  • Real-time Broadcast: real-time audio / video broadcasting, real-time subtitling, translation, events / news broadcasts.

  • IoT and connected devices: IoT real-time indicators, remote control, real-time status and location tracking.

  • Automation: Real-time trigger events based on the upstream.

 

Case: Use Azrue Functions and Azure SignaIR develop a broadcast chat room

 

Functions of the rear end of the sample code:

https://github.com/Azure-Samples/signalr-service-quickstart-serverless-chat

 

The front end of the sample code:

https://azure-samples.github.io/signalr-service-quickstart-serverless-chat/demo/chat-v2/

 

 

broadcast:

[FunctionName("SendMessage")]
public static Task SendMessage(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message, 
    [SignalR(HubName = "chat")]IAsyncCollector<SignalRMessage> signalRMessages)
{
    return signalRMessages.AddAsync(
        new SignalRMessage 
        {
            Target = "newMessage", 
            Arguments = new [] { message } 
        });
}

Unicast:

[FunctionName("SendMessage")]
public static Task SendMessage(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message, 
    [SignalR(HubName = "chat")]IAsyncCollector<SignalRMessage> signalRMessages)
{
    return signalRMessages.AddAsync(
        new SignalRMessage 
        {
            // the message will only be sent to this user ID
            UserId = "userId1",
            Target = "newMessage",
            Arguments = new [] { message }
        });
}

Multicast:

[FunctionName("SendMessage")]
public static Task SendMessage(
    [HttpTrigger(AuthorizationLevel.Anonymous, "post")]object message,
    [SignalR(HubName = "chat")]IAsyncCollector<SignalRMessage> signalRMessages)
{
    return signalRMessages.AddAsync(
        new SignalRMessage
        {
            // the message will be sent to the group with this name
            GroupName = "myGroup",
            Target = "newMessage",
            Arguments = new [] { message }
        });
}

What are the advantages of using Azure SignalR service is?

Standards provide a consistent message push:

SignalR provides an abstraction for a variety of technologies to generate real-time Web applications are. Websocket is the best transport, but when other options are not available, use other techniques servers send events (SSE) and the long polling and so on. Supported on the server and client functionality, SignalR automatically detects and initializes a suitable transmission.

Native ASP.NET Core support:

SignalR service provides local programming experience with ASP.NET Core and ASP.NET. Use SignalR SignalR service to develop new applications or migrate from existing SignalR-based application to SignalR service pay only a small amount of energy. SignalR service also supports ASP.NET Core new features: the server Blazor.

A wide range of client support:

SignalR service is available for a wide range of clients, such as Web and mobile browsers, desktop applications, mobile applications, server processes, IoT devices and game consoles. SignalR services provided SDK in different languages. In addition to the native ASP.NET Core or ASP.NET C # SDK, SignalR service also provides support JavaScript Client SDK Web client and many JavaScript frameworks. 

Java client SDK also supports Java applications, including the Android native applications. SignalR service support REST API, after integration with Azure Functions and events grid without a server.

Handling large client connections:

SignalR services for large-scale real-time application design. SignalR service allows multiple instances work together, extend to millions of client connections. The service also supports multiple global regions, in order to achieve fragmentation, high availability or disaster recovery purposes.

It eliminates the burden of self-supporting SignalR:

And a self-supporting application SignalR compared SignalR after switching the service, no need to manage the size and the rear end plane processing client connections. Fully managed service also simplifies Web application hosting and save costs. SignalR services worldwide, providing first-class data centers and networks, can scale to millions of connections, with SLA assurance, and meet all compliance and safety standards of Azure.

It provides a rich API for different messaging modes:

SignalR service allows a server to send messages to specific connections, all connections or a subset of connection belonging to a particular user or placed in any group.

Reference costs:

 

 

 

 

Guess you like

Origin www.cnblogs.com/shuzhenyu/p/12159546.html