update README for npm packages (#2216)

This commit is contained in:
Andrew Stanton-Nurse 2018-05-07 09:14:24 -07:00 committed by GitHub
parent e3e80b957c
commit 1012b36bfb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 12 deletions

View File

@ -8,16 +8,20 @@ npm install @aspnet/signalr-protocol-msgpack
## Usage ## Usage
See the [SignalR Documentation](https://docs.microsoft.com/en-us/aspnet/core/signalr) at docs.microsoft.com for documentation on the latest release.
### Browser ### 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. 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.
### Example (Browser) ### Example (Browser)
```JavaScript ```JavaScript
let connection = new signalR.HubConnection('/chat', { let connection = new signalR.HubConnectionBuilder()
protocol: new signalR.protocols.msgpack.MessagePackHubProtocol() .withUrl("/chat")
}); .withHubProtocol(new signalR.protocols.msgpack.MessagePackHubProtocol())
.build();
connection.on('send', data => { connection.on('send', data => {
console.log(data); console.log(data);
@ -33,9 +37,10 @@ connection.start()
const signalR = require("@aspnet/signalr"); const signalR = require("@aspnet/signalr");
const signalRMsgPack = require("@aspnet/signalr-protocol-msgpack"); const signalRMsgPack = require("@aspnet/signalr-protocol-msgpack");
let connection = new signalR.HubConnection('/chat', { let connection = new signalR.HubConnectionBuilder()
protocol: new signalRMsgPack.MessagePackHubProtocol() .withUrl("/chat")
}); .withHubProtocol(new signalRMsgPack.MessagePackHubProtocol())
.build();
connection.on('send', data => { connection.on('send', data => {
console.log(data); console.log(data);

View File

@ -8,6 +8,8 @@ npm install @aspnet/signalr
## Usage ## Usage
See the [SignalR Documentation](https://docs.microsoft.com/en-us/aspnet/core/signalr) at docs.microsoft.com for documentation on the latest release.
### Browser ### 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. 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.
@ -23,14 +25,16 @@ The following polyfills are required to use the client in Node.js applications:
### Example (Browser) ### Example (Browser)
```JavaScript ```JavaScript
let connection = new signalR.HubConnection('/chat'); let connection = new signalR.HubConnectionBuilder()
.withUrl("/chat")
.build();
connection.on('send', data => { connection.on("send", data => {
console.log(data); console.log(data);
}); });
connection.start() connection.start()
.then(() => connection.invoke('send', 'Hello')); .then(() => connection.invoke("send", "Hello"));
``` ```
### Example (NodeJS) ### Example (NodeJS)
@ -38,12 +42,14 @@ connection.start()
```JavaScript ```JavaScript
const signalR = require("@aspnet/signalr"); const signalR = require("@aspnet/signalr");
let connection = new signalR.HubConnection('/chat'); let connection = new signalR.HubConnectionBuilder()
.withUrl("/chat")
.build();
connection.on('send', data => { connection.on("send", data => {
console.log(data); console.log(data);
}); });
connection.start() connection.start()
.then(() => connection.invoke('send', 'Hello')); .then(() => connection.invoke("send", "Hello"));
``` ```