@b2broker/signalr
ASP.NET Core SignalR Client
Last updated 3 months ago by b2broker .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @b2broker/signalr 
SYNC missed versions from official npm registry.

JavaScript and TypeScript clients for SignalR for ASP.NET Core and Azure SignalR Service (forked from @microsoft/signalr)

Installation

npm install @b2broker/signalr
# or
yarn add @b2broker/signalr

To try previews of the next version, use the next tag on NPM:

npm install @b2broker/signalr@next
# or
yarn add @b2broker/signalr@next

Usage

See the SignalR Documentation at docs.microsoft.com for documentation on the latest release. API Reference Documentation is also available on docs.microsoft.com.

For documentation on using this client with Azure SignalR Service and Azure Functions, see the SignalR Service serverless developer guide.

Browser

To use the client in a browser, copy *.js files from the dist/browser folder to your script folder include on your page using the <script> tag.

WebWorker

To use the client in a webworker, copy *.js files from the dist/webworker folder to your script folder include on your webworker using the importScripts function. Note that webworker SignalR hub connection supports only absolute path to a SignalR hub.

Node.js

To use the client in a NodeJS application, install the package to your node_modules folder and use require('@b2broker/signalr') to load the module. The object returned by require('@b2broker/signalr') has the same members as the global signalR object (when used in a browser).

Example (Browser)

let connection = new signalR.HubConnectionBuilder()
    .withUrl("/chat")
    .build();

connection.on("send", data => {
    console.log(data);
});

connection.start()
    .then(() => connection.invoke("send", "Hello"));

Example (WebWorker)

importScripts('signalr.js');

let connection = new signalR.HubConnectionBuilder()
    .withUrl("https://example.com/signalr/chat")
    .build();

connection.on("send", data => {
    console.log(data);
});

connection.start()
    .then(() => connection.invoke("send", "Hello"));

Example (NodeJS)

const signalR = require("@b2broker/signalr");

const headers = { "X-API-KEY": "SECRET", "X-SIGNATURE": "SIGNATURE" };

let connection = new signalR.HubConnectionBuilder()
    .withUrl("/chat", { headers })
    .build();

connection.on("send", data => {
    console.log(data);
});

connection.start()
    .then(() => connection.invoke("send", "Hello"));

Current Tags

  • 1.0.0                                ...           latest (3 months ago)

1 Versions

  • 1.0.0                                ...           3 months ago
Maintainers (1)
Downloads
Today 0
This Week 1
This Month 2
Last Day 1
Last Week 1
Last Month 0
Dependencies (3)
Dev Dependencies (5)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |