var connection; function ConnectionSignalR(userInfo, event) { connection = new signalR.HubConnectionBuilder().withUrl(userInfo.url).build(); // 初始化连接 connection.start().then(function () { userInfo.ConnectionId = connection.connectionId; console.log("用户连接成功!", userInfo); // 连接用户 connection.invoke("LoginUser", JSON.stringify(userInfo)).catch(function (err) { return console.error(err.toString()); }); }).catch(function (err) { return console.error(err.toString()); }); // 用户收到消息 connection.on("ReceiveMessage", function (message, id, count) { event.receiveEvent(message, id, count); }); connection.on("MsgToolMessage", function (message, id, count) { event.msgtoolEvent(message, id, count); }); // 合规退款申请通知 connection.on("ComplaintMessage", function (message, id, count) { event.complaintEvent(message, id, count); }); // 投诉处理通知 connection.on("HgRefundMessage", function (message, id, count) { event.hgRefundEvent(message, id, count); }); connection.on("ForcedDownline", function (message) { event.forcedDownlineEvent(message); }) }