diff --git a/BarrageGrab/Properties/AssemblyInfo.cs b/BarrageGrab/Properties/AssemblyInfo.cs index 82fe99e..a36c1ed 100644 --- a/BarrageGrab/Properties/AssemblyInfo.cs +++ b/BarrageGrab/Properties/AssemblyInfo.cs @@ -33,6 +33,6 @@ using System.Runtime.InteropServices; //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 //通过使用 "*",如下所示: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("2.7.3.0")] -[assembly: AssemblyFileVersion("2.7.3.0")] +[assembly: AssemblyVersion("2.7.4.0")] +[assembly: AssemblyFileVersion("2.7.4.0")] [assembly: NeutralResourcesLanguage("zh-CN")] diff --git a/BarrageGrab/Proxy/SystemProxy.cs b/BarrageGrab/Proxy/SystemProxy.cs index 661417c..0920319 100644 --- a/BarrageGrab/Proxy/SystemProxy.cs +++ b/BarrageGrab/Proxy/SystemProxy.cs @@ -108,7 +108,8 @@ namespace BarrageGrab.Proxy { RegistryKey registry = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", true); registry.SetValue("ProxyEnable", 1); - registry.SetValue("ProxyServer", $"http=localhost:{ProxyPort};https=localhost:{ProxyPort}"); + registry.SetValue("ProxyServer", $"127.0.0.1:{ProxyPort}"); + OnProxyStatus?.Invoke(this, new SystemProxyChangeEventArgs() { Open = true diff --git a/BarrageGrab/Proxy/TitaniumProxy.cs b/BarrageGrab/Proxy/TitaniumProxy.cs index 724f3a7..33c7bb5 100644 --- a/BarrageGrab/Proxy/TitaniumProxy.cs +++ b/BarrageGrab/Proxy/TitaniumProxy.cs @@ -243,7 +243,7 @@ namespace BarrageGrab.Proxy var urlNoQuery = url.Split('?')[0]; var processid = e.HttpClient.ProcessId.Value; var processName = base.GetProcessName(processid); - var liveRoomMactch = Regex.Match(uri.Trim(), @".*:\/\/live.douyin\.com\/(\d+)"); + var liveRoomMactch = Regex.Match(uri.Trim(), @".*:\/\/live.douyin\.com\/([0-9a-zA-Z_]+)"); var liveHomeMatch = Regex.Match(uri.Trim(), @".*:\/\/live.douyin\.com\/?$"); var contentType = e.HttpClient.Response.ContentType ?? ""; @@ -586,8 +586,10 @@ namespace BarrageGrab.Proxy proxyServer.Start(AppSetting.Current.UsedProxy); if (AppSetting.Current.UsedProxy) { - proxyServer.SetAsSystemHttpProxy(explicitEndPoint); - proxyServer.SetAsSystemHttpsProxy(explicitEndPoint); + base.RegisterSystemProxy(); + //使用其自带的系统代理设置可能会导致格式问题 + //proxyServer.SetAsSystemHttpProxy(explicitEndPoint); + //proxyServer.SetAsSystemHttpsProxy(explicitEndPoint); } } } diff --git a/BarrageGrab/WssBarrageGrab.cs b/BarrageGrab/WssBarrageGrab.cs index 80e0df2..c1ed54c 100644 --- a/BarrageGrab/WssBarrageGrab.cs +++ b/BarrageGrab/WssBarrageGrab.cs @@ -125,11 +125,11 @@ namespace BarrageGrab var response = Serializer.Deserialize(new ReadOnlyMemory(allBuff)); - response.Messages.ForEach(f => DoMessage(f,e.ProcessName)); + response.Messages.ForEach(f => DoMessage(f, e.ProcessName)); } - catch (Exception ex) + catch (Exception ex) { - Logger.LogError(ex,$"处理弹幕数据包时出错:{ex.Message}"); + Logger.LogError(ex, $"处理弹幕数据包时出错:{ex.Message}"); } } @@ -142,7 +142,7 @@ namespace BarrageGrab response.Messages.ForEach(f => { - DoMessage(f,e.ProcessName); + DoMessage(f, e.ProcessName); }); } @@ -150,7 +150,7 @@ namespace BarrageGrab Dictionary> msgDic = new Dictionary>(); //发送事件 - private void DoMessage(Message msg,string processName) + private void DoMessage(Message msg, string processName) { List msgIdList; if (msgDic.ContainsKey(msg.Method)) @@ -168,7 +168,11 @@ namespace BarrageGrab } msgIdList.Add(msg.msgId); - if (msgIdList.Count > 300) msgIdList.RemoveAt(0); + //每种消息类型设置300容量应该足够,不太可能存在一条消息被挤出队列后再次出现 + while (msgIdList.Count > 300) + { + msgIdList.RemoveAt(0); + } try { @@ -178,13 +182,13 @@ namespace BarrageGrab case "WebcastMemberMessage": { var arg = Serializer.Deserialize(new ReadOnlyMemory(msg.Payload)); - this.OnMemberMessage?.Invoke(this, new RoomMessageEventArgs(processName,arg)); + this.OnMemberMessage?.Invoke(this, new RoomMessageEventArgs(processName, arg)); break; } //关注 case "WebcastSocialMessage": { - var arg = Serializer.Deserialize(new ReadOnlyMemory(msg.Payload)); + var arg = Serializer.Deserialize(new ReadOnlyMemory(msg.Payload)); this.OnSocialMessage?.Invoke(this, new RoomMessageEventArgs(processName, arg)); break; } @@ -255,7 +259,7 @@ namespace BarrageGrab public RoomMessageEventArgs() { - + } public RoomMessageEventArgs(string process, T data) diff --git a/BarrageGrab/WssBarrageService.csproj b/BarrageGrab/WssBarrageService.csproj index 493dbe9..17ed360 100644 --- a/BarrageGrab/WssBarrageService.csproj +++ b/BarrageGrab/WssBarrageService.csproj @@ -13,6 +13,8 @@ v4.6.2 512 true + false + publish\ true Disk @@ -25,10 +27,8 @@ true 0 1.0.0.%2a - false false true - true @@ -40,12 +40,12 @@ 4 - pdbonly + none true bin\Release\ TRACE prompt - 4 + 0