Add pusher.Connected check before closing pusher.
This ensures that the pusher is only closed when it is connected, preventing unnecessary operations and potential errors. The change has been applied across ChatController, GamesController, and ChallengesController.
This commit is contained in:
@@ -159,8 +159,11 @@ public class ChallengesController (
|
||||
}
|
||||
finally
|
||||
{
|
||||
await pusher.Close(HttpContext.RequestAborted);
|
||||
outSub.Unsubscribe();
|
||||
if (pusher.Connected)
|
||||
{
|
||||
await pusher.Close(HttpContext.RequestAborted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,9 +52,12 @@ public class ChatController(InMemoryDatabase database) : ControllerBase
|
||||
}
|
||||
finally
|
||||
{
|
||||
await pusher.Close(HttpContext.RequestAborted);
|
||||
outSub.Unsubscribe();
|
||||
inSub.Unsubscribe();
|
||||
if (pusher.Connected)
|
||||
{
|
||||
await pusher.Close(HttpContext.RequestAborted);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,9 +90,12 @@ public class GamesController(InMemoryDatabase database) : Controller
|
||||
}
|
||||
finally
|
||||
{
|
||||
await pusher.Close(HttpContext.RequestAborted);
|
||||
outSub.Unsubscribe();
|
||||
inSub.Unsubscribe();
|
||||
if (pusher.Connected)
|
||||
{
|
||||
await pusher.Close(HttpContext.RequestAborted);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user