From e4310ff52a750a42c9e6b7ea501a50c6f0f36adf Mon Sep 17 00:00:00 2001 From: qiuzhouwei Date: Sat, 28 Nov 2020 13:39:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BD=93=E6=97=A0=E4=BA=BA=E8=A7=82=E7=9C=8B?= =?UTF-8?q?=E6=B5=81=E4=BA=8B=E4=BB=B6=E5=8F=91=E7=94=9F=E6=97=B6=EF=BC=8C?= =?UTF-8?q?=E6=B8=85=E7=90=86=E4=B8=80=E6=AC=A1playersessionlist?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- StreamMediaServerKeeper/Common.cs | 6 ++++-- .../AutoTasker/StreamNodeKeeperMonitor.cs | 2 +- .../Controllers/WebHookController.cs | 20 +++++++++++++++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/StreamMediaServerKeeper/Common.cs b/StreamMediaServerKeeper/Common.cs index cfef405..2029b54 100644 --- a/StreamMediaServerKeeper/Common.cs +++ b/StreamMediaServerKeeper/Common.cs @@ -362,12 +362,14 @@ private static bool checkMediaServerBin(string filePath) public static void KillSelf(string message = "") { Logger.Logger.Fatal("异常情况,结束自己进程..." + "-> " + message); - string fileName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); + Environment.Exit(0); + /*string fileName = Path.GetFileName(Environment.GetCommandLineArgs()[0]); Process[] processes = Process.GetProcessesByName(Path.GetFileNameWithoutExtension(fileName)); if (processes.Length > 0) { processes[0].Kill(); - } + }*/ + } diff --git a/StreamNodeWebApi/AutoTasker/StreamNodeKeeperMonitor.cs b/StreamNodeWebApi/AutoTasker/StreamNodeKeeperMonitor.cs index 60c1ef1..5f38968 100644 --- a/StreamNodeWebApi/AutoTasker/StreamNodeKeeperMonitor.cs +++ b/StreamNodeWebApi/AutoTasker/StreamNodeKeeperMonitor.cs @@ -19,7 +19,7 @@ private void Monitor() { try { - for (int i = Common.MediaServerList.Count - 1; i <= 0; i--) + for (int i = Common.MediaServerList.Count - 1; i >= 0; i--) { if (Common.MediaServerList[i] != null && Common.MediaServerList[i].Health) { diff --git a/StreamNodeWebApi/Controllers/WebHookController.cs b/StreamNodeWebApi/Controllers/WebHookController.cs index 8d2db02..0de0f1d 100644 --- a/StreamNodeWebApi/Controllers/WebHookController.cs +++ b/StreamNodeWebApi/Controllers/WebHookController.cs @@ -1,5 +1,6 @@ using System; using System.Net; +using CommonFunction.ManageStructs; using CommonFunctions; using CommonFunctions.ManageStructs; using CommonFunctions.WebApiStructs.Request; @@ -140,6 +141,25 @@ public ResToWebHookOnStreamChange OnStreamChange(ReqForWebHookOnStreamChange req [AuthVerify] public ResToWebHookOnStreamNoneReader OnStreamNoneReader(ReqForWebHookOnStreamNoneReader req) { + lock (Common.PlayerSessionListLock) + { + for (int i = Common.PlayerSessions.Count - 1; i >= 0; i--) + { + if (Common.PlayerSessions[i] != null && + Common.PlayerSessions[i].App!.Equals(req.App) && + Common.PlayerSessions[i].Vhost!.Equals(req.Vhost) + && Common.PlayerSessions[i].StreamId! + .Equals(req.Stream) && Common.PlayerSessions[i] + .MediaServerId!.Equals(req.MediaServerId)) + { + Common.PlayerSessions[i] = null!; + break; + } + } + + Common.RemoveNull(Common.PlayerSessions); + } + return new ResToWebHookOnStreamNoneReader() { Code = 0,