From 92338ab006f0e23f286a0914e4456c4f3a1c1b7b Mon Sep 17 00:00:00 2001
From: hwh <332078369@qq.com>
Date: 星期五, 06 九月 2024 10:48:50 +0800
Subject: [PATCH] 日志
---
Web/src/views/device/deviceInfo/signalR.ts | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/Web/src/views/device/deviceInfo/signalR.ts b/Web/src/views/device/deviceInfo/signalR.ts
new file mode 100644
index 0000000..6196950
--- /dev/null
+++ b/Web/src/views/device/deviceInfo/signalR.ts
@@ -0,0 +1,37 @@
+import * as SignalR from '@microsoft/signalr';
+import { getToken } from '/@/utils/axios-utils';
+
+// 鍒濆鍖朣ignalR瀵硅薄
+const connection = new SignalR.HubConnectionBuilder()
+ .configureLogging(SignalR.LogLevel.Information)
+ .withUrl(`${window.__env__.VITE_API_URL}/hubs/Plc?token=${getToken()}`, { transport: SignalR.HttpTransportType.WebSockets, skipNegotiation: true })
+ .withAutomaticReconnect({
+ nextRetryDelayInMilliseconds: () => {
+ return 5000; // 姣�5绉掗噸杩炰竴娆�
+ },
+ })
+ .build();
+
+connection.keepAliveIntervalInMilliseconds = 15 * 1000; // 蹇冭烦妫�娴�15s
+connection.serverTimeoutInMilliseconds = 30 * 60 * 1000; // 瓒呮椂鏃堕棿30m
+
+// 鍚姩杩炴帴
+connection.start().then(() => {
+ console.log('鍚姩杩炴帴plc');
+});
+// 鏂紑杩炴帴
+connection.onclose(async () => {
+ console.log('鏂紑杩炴帴plc');
+});
+// 閲嶈繛涓�
+connection.onreconnecting(() => {
+ console.log('鏈嶅姟鍣ㄥ凡鏂嚎plc');
+});
+// 閲嶈繛鎴愬姛
+connection.onreconnected(() => {
+ console.log('閲嶈繛鎴愬姛plc');
+});
+
+// connection.on('PublicPlcConn', () => {});
+
+export { connection as signalR };
--
Gitblit v1.8.0