Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/signalr

Package Overview
Dependencies
Maintainers
5
Versions
132
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/signalr

ASP.NET Core SignalR Client

  • 6.0.25
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
486K
decreased by-15.94%
Maintainers
5
Weekly downloads
 
Created

What is @microsoft/signalr?

@microsoft/signalr is a library for ASP.NET developers that simplifies the process of adding real-time web functionality to applications. It allows server-side code to push content to connected clients instantly as it becomes available, rather than having the server wait for a client to request new data.

What are @microsoft/signalr's main functionalities?

Establishing a Connection

This code demonstrates how to establish a connection to a SignalR hub. The `HubConnectionBuilder` is used to configure and create a connection to the specified hub URL.

const signalR = require('@microsoft/signalr');

const connection = new signalR.HubConnectionBuilder()
    .withUrl('/chatHub')
    .build();

connection.start().then(() => console.log('Connection started')).catch(err => console.error(err));

Sending Messages

This code shows how to send a message to the server using the `invoke` method. The first parameter is the name of the server method to call, and the subsequent parameters are the arguments to pass to that method.

connection.invoke('SendMessage', 'Hello, World!').catch(err => console.error(err));

Receiving Messages

This code demonstrates how to set up a client-side handler for messages sent from the server. The `on` method is used to specify the name of the server method to handle and a callback function to execute when the method is called.

connection.on('ReceiveMessage', (user, message) => {
    console.log(`${user}: ${message}`);
});

Other packages similar to @microsoft/signalr

Keywords

FAQs

Package last updated on 14 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc