Merge pull request #2220 from aspnet/release/2.1
update README for npm packages (#2216)
This commit is contained in:
commit
f163670bec
|
|
@ -8,16 +8,20 @@ npm install @aspnet/signalr-protocol-msgpack
|
|||
|
||||
## 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
|
||||
|
||||
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)
|
||||
|
||||
```JavaScript
|
||||
let connection = new signalR.HubConnection('/chat', {
|
||||
protocol: new signalR.protocols.msgpack.MessagePackHubProtocol()
|
||||
});
|
||||
let connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("/chat")
|
||||
.withHubProtocol(new signalR.protocols.msgpack.MessagePackHubProtocol())
|
||||
.build();
|
||||
|
||||
connection.on('send', data => {
|
||||
console.log(data);
|
||||
|
|
@ -33,9 +37,10 @@ connection.start()
|
|||
const signalR = require("@aspnet/signalr");
|
||||
const signalRMsgPack = require("@aspnet/signalr-protocol-msgpack");
|
||||
|
||||
let connection = new signalR.HubConnection('/chat', {
|
||||
protocol: new signalRMsgPack.MessagePackHubProtocol()
|
||||
});
|
||||
let connection = new signalR.HubConnectionBuilder()
|
||||
.withUrl("/chat")
|
||||
.withHubProtocol(new signalRMsgPack.MessagePackHubProtocol())
|
||||
.build();
|
||||
|
||||
connection.on('send', data => {
|
||||
console.log(data);
|
||||
|
|
|
|||
|
|
@ -8,6 +8,8 @@ npm install @aspnet/signalr
|
|||
|
||||
## 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
|
||||
|
||||
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)
|
||||
|
||||
```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);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke('send', 'Hello'));
|
||||
.then(() => connection.invoke("send", "Hello"));
|
||||
```
|
||||
|
||||
### Example (NodeJS)
|
||||
|
|
@ -38,12 +42,14 @@ connection.start()
|
|||
```JavaScript
|
||||
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);
|
||||
});
|
||||
|
||||
connection.start()
|
||||
.then(() => connection.invoke('send', 'Hello'));
|
||||
.then(() => connection.invoke("send", "Hello"));
|
||||
```
|
||||
|
|
|
|||
Loading…
Reference in New Issue