hwh
2024-09-10 eff7a7ff6ee1851094dfe1f94dd40a98535865d8
Web/src/views/device/deviceMonitor/signalR.ts
@@ -17,21 +17,33 @@
// 启动连接
connection.start().then(() => {
   debugger;
   console.log('启动连接plc');
});
// 断开连接
connection.onclose(async () => {
   debugger;
   console.log('断开连接plc');
});
// 重连中
connection.onreconnecting(() => {
   debugger;
   console.log('服务器已断线plc');
});
// 重连成功
connection.onreconnected(() => {
   debugger;
   console.log('重连成功plc');
});
// 关闭连接的方法
async function stopConnection() {
   try {
     await connection.stop();
     console.log('连接已关闭');
   } catch (error) {
     console.error('关闭连接时发生错误:', error);
   }
  }
// connection.on('PublicPlcConn', () => {});
export { connection as signalR };
export { connection as signalR,stopConnection };