facade-signalr-client
v1.0.6
Published
facade signalr client
Downloads
4
Readme
signalr client
基于 @microsoft/signalr 客户端
使用
yarn add facade-signalr-client
js 客户端使用
import signalrClient from 'facade-signalr-client'
try {
// register events signalr.connected
signalrClient.events.on('signalr.connected', connection => {
console.log(connection, 'signalr.connected')
})
// connect
signalrClient.connect('baseUrl', queryString)
// Received
signalrClient.receiveMessage('ReceivedMethod', arg => {
console.log('Received:' + arg)
})
} catch (err) {
console.log(err)
}
// Send message
signalrClient.sendMessage('SendMethod', 'args').then(response => {
console.log('response:' + response)
})
服务端 使用
public async Task<string> SendMethod(string args)
{
await Clients.All.SendAsync("ReceivedMethod", args);
return "发送成功";
}