.NET CORE SignalR Flutter 客户端
2020-06-09 本文已影响0人
老中医167788
依赖
dependencies:
signalr_core: version
例子
final connection = HubConnectionBuilder().withUrl('http://localhost:5000/chatHub',
HttpConnectionOptions(
transport: HttpTransportType.longPolling,
accessTokenFactory:()async => await Future.value("access_token"),
logging: (level, message) => print(message),
)).build();
await connection.start();
// 监听消息
connection.on('ReceiveMessage', (message) {
print(message.toString());
});
// 发送消息
await connection.invoke('SendMessage', args: ['Bob', 'Says hi!']);