fix: 尝试修复hub的scantask的key的问题
This commit is contained in:
		@@ -70,7 +70,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
 | 
			
		||||
    private readonly IHubContext<DigitalTubesHub, IDigitalTubesReceiver> _hubContext;
 | 
			
		||||
    private readonly Database.UserManager _userManager = new();
 | 
			
		||||
 | 
			
		||||
    private ConcurrentDictionary<(string, string), DigitalTubesScanTaskInfo> _scanTasks = new();
 | 
			
		||||
    private ConcurrentDictionary<string, DigitalTubesScanTaskInfo> _scanTasks = new();
 | 
			
		||||
 | 
			
		||||
    public DigitalTubesHub(IHubContext<DigitalTubesHub, IDigitalTubesReceiver> hubContext)
 | 
			
		||||
    {
 | 
			
		||||
@@ -160,7 +160,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
 | 
			
		||||
            var key = (board.ID.ToString(), Context.ConnectionId);
 | 
			
		||||
            var key = board.ID.ToString();
 | 
			
		||||
 | 
			
		||||
            if (_scanTasks.TryGetValue(key, out var existing) && existing.IsRunning)
 | 
			
		||||
                return true;
 | 
			
		||||
@@ -187,7 +187,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
 | 
			
		||||
            var key = (board.ID.ToString(), Context.ConnectionId);
 | 
			
		||||
            var key = board.ID.ToString();
 | 
			
		||||
 | 
			
		||||
            if (_scanTasks.TryRemove(key, out var scanInfo))
 | 
			
		||||
            {
 | 
			
		||||
@@ -214,7 +214,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
 | 
			
		||||
                return false;
 | 
			
		||||
 | 
			
		||||
            var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
 | 
			
		||||
            var key = (board.ID.ToString(), Context.ConnectionId);
 | 
			
		||||
            var key = board.ID.ToString();
 | 
			
		||||
 | 
			
		||||
            if (_scanTasks.TryGetValue(key, out var scanInfo) && scanInfo.IsRunning)
 | 
			
		||||
            {
 | 
			
		||||
@@ -239,7 +239,7 @@ public class DigitalTubesHub : Hub<IDigitalTubesReceiver>, IDigitalTubesHub
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
 | 
			
		||||
            var key = (board.ID.ToString(), Context.ConnectionId);
 | 
			
		||||
            var key = board.ID.ToString();
 | 
			
		||||
 | 
			
		||||
            if (_scanTasks.TryGetValue(key, out var scanInfo))
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
@@ -86,7 +86,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
 | 
			
		||||
    private readonly IHubContext<OscilloscopeHub, IOscilloscopeReceiver> _hubContext;
 | 
			
		||||
    private readonly Database.UserManager _userManager = new();
 | 
			
		||||
 | 
			
		||||
    private ConcurrentDictionary<(string, string), OscilloscopeScanTaskInfo> _scanTasks = new();
 | 
			
		||||
    private ConcurrentDictionary<string, OscilloscopeScanTaskInfo> _scanTasks = new();
 | 
			
		||||
 | 
			
		||||
    public OscilloscopeHub(IHubContext<OscilloscopeHub, IOscilloscopeReceiver> hubContext)
 | 
			
		||||
    {
 | 
			
		||||
@@ -176,7 +176,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
 | 
			
		||||
        try
 | 
			
		||||
        {
 | 
			
		||||
            var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
 | 
			
		||||
            var key = (board.ID.ToString(), Context.ConnectionId);
 | 
			
		||||
            var key = board.ID.ToString();
 | 
			
		||||
            var client = GetOscilloscope().OrThrow(() => new Exception("Oscilloscope not found"));
 | 
			
		||||
 | 
			
		||||
            if (_scanTasks.TryGetValue(key, out var existing))
 | 
			
		||||
@@ -210,7 +210,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
 | 
			
		||||
            var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
 | 
			
		||||
            var client = GetOscilloscope().OrThrow(() => new Exception("Oscilloscope not found"));
 | 
			
		||||
 | 
			
		||||
            var key = (board.ID.ToString(), Context.ConnectionId);
 | 
			
		||||
            var key = board.ID.ToString();
 | 
			
		||||
 | 
			
		||||
            if (_scanTasks.TryRemove(key, out var taskInfo))
 | 
			
		||||
            {
 | 
			
		||||
@@ -383,7 +383,7 @@ public class OscilloscopeHub : Hub<IOscilloscopeReceiver>, IOscilloscopeHub
 | 
			
		||||
                return false;
 | 
			
		||||
 | 
			
		||||
            var board = TryGetBoard().OrThrow(() => new Exception("Board not found"));
 | 
			
		||||
            var key = (board.ID.ToString(), Context.ConnectionId);
 | 
			
		||||
            var key = board.ID.ToString();
 | 
			
		||||
 | 
			
		||||
            if (_scanTasks.TryGetValue(key, out var scanInfo))
 | 
			
		||||
            {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user