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

@archetypical/auto-hub-connection

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@archetypical/auto-hub-connection

Auto reconnecting wrapper for SignalR client

  • 1.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
increased by425%
Maintainers
1
Weekly downloads
 
Created
Source

AutoHubConnection

AutoHubConnection is a simple wrapper to the .net core signalr client implementation. It automates the logic necessary to reconnecting after a unexpected disconnect.

Installation

Install globally via npm:

npm install -g @archetypical/auto-hub-connection

Or globally via yarn:

yarn global add @archetypical/auto-hub-connection

Usage

Once you have established your server side hub, you can connect to it with a new AutoHubConnection. It includes all the same methods provided by the signalr client with the same expected functionality.

In addition to the existing functionality, AutoHubConnection provides simple instantiation of a new connection and the logic to automatically reconnect when there is a network disconnect.

Instantiation

When creating a new AutoHubConnection, you must provide a host.

const autoHubConnection = new AutoHubConnection('/MyHubPath');

Optionally you can provide configuration settings used to change the reconnect behavior.

const autoHubConnection = new AutoHubConnection('/MyHubPath', {
    logLevel: LogLevel.Error,
    retryInterval: 3000,
    maxConnectionAttempts: 5
});

logLevel: The log level the underlying signalr client will log at. Default value is LogLevel.Error.

retryInterval: Defines the wait interval between connection attempts in milliseconds. Default value is 5000.

maxConnectionAttempts: Max number of attempts to initiate a connection. Default value is 5.

Example

const autoHubConnection = new AutoHubConnection('/MyHubUrl');
autoHubConnection.on('EventName', x => console.log(x));
autoHubConnection.start();

For more detail on how to utilize the signalr client, please reference the official documentation.

Keywords

FAQs

Package last updated on 11 Feb 2019

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