Sim*_*mon 2 javascript asp.net websocket signalr asp.net-core-2.1
我遵循了本教程。
但是没有提示如何通过-file 中的HubConnection类关闭 Websocket 连接signalr.js。文件为V1.0.4。
此解决方案不能解决我的问题,因为我使用的是 microsofts javascript-library。
这是代码:
var lHubConnection = null;
var Init = function () {
// create instance
lHubConnection = new signalR.lHubConnectionBuilder().withUrl("/chatHub").build();
// receive message
lHubConnection.on("ReceiveMessage", function (pMessage) {
// show message
console.log(JSON.parse(pMessage));
});
// [...]
};
// close websocket connection
var CloseConnection = function(){
if (lHubConnection !== null && lHubConnection.connection.connectionState === 1) {
// lHubConnection.invoke("?"); ???
}
};
Run Code Online (Sandbox Code Playgroud)
这是 lHubConnection 实例的控制台输出:
| 归档时间: |
|
| 查看次数: |
4675 次 |
| 最近记录: |