😎1、优化SignalR配置 2、恢复消息发送
This commit is contained in:
parent
572b3bf72f
commit
e8daf7aa5b
@ -185,7 +185,10 @@ public class Startup : AppStartup
|
||||
//services.AddSingleton<IUserIdProvider, UserIdProvider>();
|
||||
services.AddSignalR(options =>
|
||||
{
|
||||
options.KeepAliveInterval = TimeSpan.FromSeconds(5);
|
||||
options.EnableDetailedErrors = true;
|
||||
options.KeepAliveInterval = TimeSpan.FromSeconds(15); // 服务器端向客户端ping的间隔
|
||||
options.ClientTimeoutInterval = TimeSpan.FromSeconds(30); // 客户端向服务器端ping的间隔
|
||||
options.MaximumReceiveMessageSize = 1024 * 1014 * 10; // 数据包大小10M,默认最大为32K
|
||||
}).AddNewtonsoftJsonProtocol(options => SetNewtonsoftJsonSetting(options.PayloadSerializerSettings));
|
||||
|
||||
// 系统日志
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
"name": "admin.net.pro",
|
||||
"type": "module",
|
||||
"version": "2.4.33",
|
||||
"lastBuildTime": "2024.07.17",
|
||||
"lastBuildTime": "2024.07.18",
|
||||
"description": "Admin.NET 站在巨人肩膀上的 .NET 通用权限开发框架",
|
||||
"author": "zuohuaijun",
|
||||
"license": "MIT",
|
||||
@ -68,7 +68,7 @@
|
||||
"vue-signature-pad": "^3.0.2",
|
||||
"vue3-tree-org": "^4.2.2",
|
||||
"vuedraggable": "4.0.3",
|
||||
"vxe-pc-ui": "^4.0.73",
|
||||
"vxe-pc-ui": "^4.0.74",
|
||||
"vxe-table": "^4.7.54",
|
||||
"vxe-table-plugin-element": "^4.0.4",
|
||||
"vxe-table-plugin-export-xlsx": "^4.0.5",
|
||||
|
||||
@ -15,6 +15,10 @@ const connection = new SignalR.HubConnectionBuilder()
|
||||
|
||||
connection.keepAliveIntervalInMilliseconds = 15 * 1000; // 心跳检测15s
|
||||
connection.serverTimeoutInMilliseconds = 30 * 60 * 1000; // 超时时间30m
|
||||
// 若30s内没有收到服务器端发过来的信息,则认为服务器端异常
|
||||
connection.serverTimeoutInMilliseconds = 30 * 1000;
|
||||
// 若15s内没有向服务器发送任何消息,则ping一下服务器端
|
||||
connection.keepAliveIntervalInMilliseconds = 15 * 1000;
|
||||
|
||||
// 启动连接
|
||||
connection.start().then(() => {
|
||||
@ -40,4 +44,20 @@ connection.onreconnected(() => {
|
||||
|
||||
connection.on('OnlineUserList', () => {});
|
||||
|
||||
// 接收消息
|
||||
connection.on('ReceiveMessage', (message: any) => {
|
||||
var tmpMsg = `${message.message}<br/>`;
|
||||
tmpMsg += `<p style="color:#808080; font-size:12px">发送人员:${message.sendUserName}<p>`;
|
||||
tmpMsg += `<p style="color:#808080; font-size:12px">发送时间:${message.sendTime}<p>`;
|
||||
|
||||
ElNotification({
|
||||
title: `消息【${message.title}】`,
|
||||
message: tmpMsg,
|
||||
type: 'info',
|
||||
position: 'top-right',
|
||||
dangerouslyUseHTMLString: true,
|
||||
duration: 0,
|
||||
});
|
||||
});
|
||||
|
||||
export { connection as signalR };
|
||||
|
||||
Loading…
Reference in New Issue
Block a user