v2.7.2 更新
This commit is contained in:
@@ -7,7 +7,6 @@ using System.Runtime.CompilerServices;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using BarrageGrab.Modles;
|
using BarrageGrab.Modles;
|
||||||
using ColorConsole;
|
|
||||||
|
|
||||||
namespace BarrageGrab
|
namespace BarrageGrab
|
||||||
{
|
{
|
||||||
@@ -163,6 +162,17 @@ namespace BarrageGrab
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据webRoomid从缓存获取房间信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="webrid"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public RoomInfo GetByWebRoomid(string webrid)
|
||||||
|
{
|
||||||
|
var find = RoomInfoCache.FirstOrDefault(p => p.Value.WebRoomId == webrid);
|
||||||
|
return find.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public class RoomCacheEventArgs : EventArgs
|
public class RoomCacheEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using System.Net.WebSockets;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Timers;
|
using System.Timers;
|
||||||
using ColorConsole;
|
|
||||||
using Fleck;
|
using Fleck;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using BarrageGrab.Modles;
|
using BarrageGrab.Modles;
|
||||||
@@ -17,6 +16,7 @@ using System.IO;
|
|||||||
using BarrageGrab.Modles.JsonEntity;
|
using BarrageGrab.Modles.JsonEntity;
|
||||||
using BarrageGrab.Modles.ProtoEntity;
|
using BarrageGrab.Modles.ProtoEntity;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
|
||||||
namespace BarrageGrab
|
namespace BarrageGrab
|
||||||
{
|
{
|
||||||
@@ -28,10 +28,9 @@ namespace BarrageGrab
|
|||||||
WebSocketServer socketServer;
|
WebSocketServer socketServer;
|
||||||
Dictionary<string, UserState> socketList = new Dictionary<string, UserState>();
|
Dictionary<string, UserState> socketList = new Dictionary<string, UserState>();
|
||||||
//礼物计数缓存
|
//礼物计数缓存
|
||||||
Dictionary<string, Tuple<int, DateTime>> giftCountCache = new Dictionary<string, Tuple<int, DateTime>>();
|
ConcurrentDictionary<string, Tuple<int, DateTime>> giftCountCache = new ConcurrentDictionary<string, Tuple<int, DateTime>>();
|
||||||
Timer dieout = new Timer(10000);
|
Timer dieout = new Timer(10000);
|
||||||
Timer giftCountTimer = new Timer(10000);
|
Timer giftCountTimer = new Timer(10000);
|
||||||
ConsoleWriter console = new ConsoleWriter();
|
|
||||||
WssBarrageGrab grab = new WssBarrageGrab();
|
WssBarrageGrab grab = new WssBarrageGrab();
|
||||||
Appsetting Appsetting = Appsetting.Current;
|
Appsetting Appsetting = Appsetting.Current;
|
||||||
bool debug = false;
|
bool debug = false;
|
||||||
@@ -92,7 +91,7 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
timeOutKeys.ForEach(key =>
|
timeOutKeys.ForEach(key =>
|
||||||
{
|
{
|
||||||
giftCountCache.Remove(key);
|
giftCountCache.TryRemove(key, out _);
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -100,8 +99,12 @@ namespace BarrageGrab
|
|||||||
|
|
||||||
private bool CheckRoomId(long roomid)
|
private bool CheckRoomId(long roomid)
|
||||||
{
|
{
|
||||||
if (Appsetting.RoomIds.Length == 0) return true;
|
if (!Appsetting.Current.WebRoomIds.Any()) return true;
|
||||||
return Appsetting.RoomIds.Any(a => a == roomid);
|
|
||||||
|
var webrid = AppRuntime.RoomCaches.GetCachedWebRoomid(roomid.ToString());
|
||||||
|
if (webrid <= 0) return true;
|
||||||
|
|
||||||
|
return Appsetting.Current.WebRoomIds.Contains(webrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
//解析用户
|
//解析用户
|
||||||
@@ -179,10 +182,10 @@ namespace BarrageGrab
|
|||||||
if (++count > 10000)
|
if (++count > 10000)
|
||||||
{
|
{
|
||||||
Console.Clear();
|
Console.Clear();
|
||||||
Console.WriteLine("控制台已清理");
|
Logger.PrintColor("控制台已清理");
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
console.WriteLine(text + "\n", color);
|
Logger.PrintColor(text + "\n", color);
|
||||||
}
|
}
|
||||||
|
|
||||||
//粉丝团
|
//粉丝团
|
||||||
@@ -238,22 +241,21 @@ namespace BarrageGrab
|
|||||||
|
|
||||||
var key = msg.Common.roomId + "-" + msg.giftId + "-" + msg.groupId.ToString();
|
var key = msg.Common.roomId + "-" + msg.giftId + "-" + msg.groupId.ToString();
|
||||||
|
|
||||||
|
int currCount = (int)msg.repeatCount;
|
||||||
|
int lastCount = 0;
|
||||||
|
//Combo 为1时,表示为可连击礼物
|
||||||
|
if (msg.Gift.Combo)
|
||||||
|
{
|
||||||
//判断礼物重复
|
//判断礼物重复
|
||||||
if (msg.repeatEnd == 1)
|
if (msg.repeatEnd == 1)
|
||||||
{
|
{
|
||||||
//清除缓存中的key
|
//清除缓存中的key
|
||||||
if (msg.groupId > 0 && giftCountCache.ContainsKey(key))
|
if (msg.groupId > 0 && giftCountCache.ContainsKey(key))
|
||||||
{
|
{
|
||||||
lock (giftCountCache)
|
giftCountCache.TryRemove(key, out _);
|
||||||
{
|
|
||||||
giftCountCache.Remove(key);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int lastCount = 0;
|
|
||||||
int currCount = (int)msg.repeatCount;
|
|
||||||
var backward = currCount <= lastCount;
|
var backward = currCount <= lastCount;
|
||||||
if (currCount <= 0) currCount = 1;
|
if (currCount <= 0) currCount = 1;
|
||||||
|
|
||||||
@@ -273,15 +275,12 @@ namespace BarrageGrab
|
|||||||
{
|
{
|
||||||
if (msg.groupId > 0 && !backward)
|
if (msg.groupId > 0 && !backward)
|
||||||
{
|
{
|
||||||
lock (giftCountCache)
|
giftCountCache.TryAdd(key, Tuple.Create(currCount, DateTime.Now));
|
||||||
{
|
|
||||||
giftCountCache.Add(key, Tuple.Create(currCount, DateTime.Now));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//比上次小,则说明先后顺序出了问题,直接丢掉,应为比它大的消息已经处理过了
|
//比上次小,则说明先后顺序出了问题,直接丢掉,应为比它大的消息已经处理过了
|
||||||
if (backward) return;
|
if (backward) return;
|
||||||
|
}
|
||||||
|
|
||||||
var count = currCount - lastCount;
|
var count = currCount - lastCount;
|
||||||
|
|
||||||
@@ -290,13 +289,15 @@ namespace BarrageGrab
|
|||||||
MsgId = msg.Common.msgId,
|
MsgId = msg.Common.msgId,
|
||||||
RoomId = msg.Common.roomId,
|
RoomId = msg.Common.roomId,
|
||||||
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
|
||||||
Content = $"{msg.User.Nickname} 送出 {msg.Gift.Name} x {currCount} 个,增量{count}个",
|
Content = $"{msg.User.Nickname} 送出 {msg.Gift.Name}{(msg.Gift.Combo ? "(可连击)" : "")} x {msg.repeatCount}个,增量{count}个",
|
||||||
DiamondCount = msg.Gift.diamondCount,
|
DiamondCount = msg.Gift.diamondCount,
|
||||||
RepeatCount = currCount,
|
RepeatCount = msg.repeatCount,
|
||||||
GiftCount = count,
|
GiftCount = count,
|
||||||
GroupId = msg.groupId,
|
GroupId = msg.groupId,
|
||||||
GiftId = msg.giftId,
|
GiftId = msg.giftId,
|
||||||
GiftName = msg.Gift.Name,
|
GiftName = msg.Gift.Name,
|
||||||
|
Combo = msg.Gift.Combo,
|
||||||
|
ImgUrl = msg.Gift.Image?.urlLists?.FirstOrDefault()??"",
|
||||||
User = GetUser(msg.User),
|
User = GetUser(msg.User),
|
||||||
ToUser = GetUser(msg.toUser)
|
ToUser = GetUser(msg.toUser)
|
||||||
};
|
};
|
||||||
@@ -471,9 +472,9 @@ namespace BarrageGrab
|
|||||||
// if (++count > 1000)
|
// if (++count > 1000)
|
||||||
// {
|
// {
|
||||||
// Console.Clear();
|
// Console.Clear();
|
||||||
// Console.WriteLine("控制台已清理");
|
// Logger.PrintColor("控制台已清理");
|
||||||
// }
|
// }
|
||||||
// console.WriteLine($"{DateTime.Now.ToString("HH:mm:ss")} [{bartype.ToString()}] " + msg + "\n", color);
|
// Logger.PrintColor($"{DateTime.Now.ToString("HH:mm:ss")} [{bartype.ToString()}] " + msg + "\n", color);
|
||||||
// count = 0;
|
// count = 0;
|
||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
@@ -492,7 +493,7 @@ namespace BarrageGrab
|
|||||||
if (!socketList.ContainsKey(clientUrl))
|
if (!socketList.ContainsKey(clientUrl))
|
||||||
{
|
{
|
||||||
socketList.Add(clientUrl, new UserState(socket));
|
socketList.Add(clientUrl, new UserState(socket));
|
||||||
console.WriteLine($"{DateTime.Now.ToLongTimeString()} 已经建立与[{clientUrl}]的连接", ConsoleColor.Green);
|
Logger.PrintColor($"{DateTime.Now.ToLongTimeString()} 已经建立与[{clientUrl}]的连接", ConsoleColor.Green);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -535,7 +536,7 @@ namespace BarrageGrab
|
|||||||
socket.OnClose = () =>
|
socket.OnClose = () =>
|
||||||
{
|
{
|
||||||
socketList.Remove(clientUrl);
|
socketList.Remove(clientUrl);
|
||||||
console.WriteLine($"{DateTime.Now.ToLongTimeString()} 已经关闭与[{clientUrl}]的连接", ConsoleColor.Red);
|
Logger.PrintColor($"{DateTime.Now.ToLongTimeString()} 已经关闭与[{clientUrl}]的连接", ConsoleColor.Red);
|
||||||
};
|
};
|
||||||
|
|
||||||
socket.OnPing = (data) =>
|
socket.OnPing = (data) =>
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using ProtoBuf;
|
using ProtoBuf;
|
||||||
using ColorConsole;
|
|
||||||
using BarrageGrab.Proxy;
|
using BarrageGrab.Proxy;
|
||||||
using BarrageGrab.Proxy.ProxyEventArgs;
|
using BarrageGrab.Proxy.ProxyEventArgs;
|
||||||
using BarrageGrab.Modles.ProtoEntity;
|
using BarrageGrab.Modles.ProtoEntity;
|
||||||
@@ -21,7 +20,6 @@ namespace BarrageGrab
|
|||||||
//ISystemProxy proxy = new FiddlerProxy();
|
//ISystemProxy proxy = new FiddlerProxy();
|
||||||
ISystemProxy proxy = new TitaniumProxy();
|
ISystemProxy proxy = new TitaniumProxy();
|
||||||
Appsetting appsetting = Appsetting.Current;
|
Appsetting appsetting = Appsetting.Current;
|
||||||
ConsoleWriter console = new ConsoleWriter();
|
|
||||||
//解包成功的域名缓存
|
//解包成功的域名缓存
|
||||||
List<string> succPackHostNames = new List<string>();
|
List<string> succPackHostNames = new List<string>();
|
||||||
|
|
||||||
@@ -248,7 +246,7 @@ namespace BarrageGrab
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
console.WriteLine("未能识别的礼物ID:" + arg.giftId, ConsoleColor.Red);
|
Logger.PrintColor("未能识别的礼物ID:" + arg.giftId, ConsoleColor.Red);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -312,7 +310,7 @@ namespace BarrageGrab
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine("写入成功解包域名缓存失败:" + ex.Message, ConsoleColor.Red);
|
Logger.PrintColor("写入成功解包域名缓存失败:" + ex.Message, ConsoleColor.Red);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,9 +70,6 @@
|
|||||||
<Reference Include="BrotliSharpLib, Version=0.3.2.0, Culture=neutral, PublicKeyToken=3f4e2a1cd615fcb7, processorArchitecture=MSIL">
|
<Reference Include="BrotliSharpLib, Version=0.3.2.0, Culture=neutral, PublicKeyToken=3f4e2a1cd615fcb7, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\BrotliSharpLib.0.3.3\lib\net451\BrotliSharpLib.dll</HintPath>
|
<HintPath>..\packages\BrotliSharpLib.0.3.3\lib\net451\BrotliSharpLib.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ColorConsole, Version=1.0.1.0, Culture=neutral, processorArchitecture=MSIL">
|
|
||||||
<HintPath>..\packages\ColorConsole.1.0.1\lib\net40\ColorConsole.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Fleck, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Fleck, Version=1.2.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\Fleck.1.2.0\lib\net45\Fleck.dll</HintPath>
|
<HintPath>..\packages\Fleck.1.2.0\lib\net45\Fleck.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
@@ -139,15 +136,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AppRuntime.cs" />
|
<Compile Include="AppRuntime.cs" />
|
||||||
<Compile Include="Appsetting.cs" />
|
<Compile Include="Appsetting.cs" />
|
||||||
<Compile Include="Forms - 复制\FormView.cs" />
|
|
||||||
<Compile Include="Forms - 复制\FormView.Designer.cs">
|
|
||||||
<DependentUpon>FormView.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Forms - 复制\Models\RoomCacheItem.cs" />
|
|
||||||
<Compile Include="Forms - 复制\RoomDetail.cs" />
|
|
||||||
<Compile Include="Forms - 复制\RoomDetail.Designer.cs">
|
|
||||||
<DependentUpon>RoomDetail.cs</DependentUpon>
|
|
||||||
</Compile>
|
|
||||||
<Compile Include="Forms\FormView.cs">
|
<Compile Include="Forms\FormView.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -207,12 +195,6 @@
|
|||||||
</BootstrapperPackage>
|
</BootstrapperPackage>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<EmbeddedResource Include="Forms - 复制\FormView.resx">
|
|
||||||
<DependentUpon>FormView.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Forms - 复制\RoomDetail.resx">
|
|
||||||
<DependentUpon>RoomDetail.cs</DependentUpon>
|
|
||||||
</EmbeddedResource>
|
|
||||||
<EmbeddedResource Include="Forms\FormView.resx">
|
<EmbeddedResource Include="Forms\FormView.resx">
|
||||||
<DependentUpon>FormView.cs</DependentUpon>
|
<DependentUpon>FormView.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
|
|||||||
Reference in New Issue
Block a user