1. 添加了上游代理支持,现在可以将无关的请求转发到其他的代理地址!详见下方配置说明upstreamProxy
2. 内部添加了webRoomid 的缓存映射,只要打开直播间地址即可缓存WebRoomId和Roomid的映射关系,`WebRoomId`现已添加至ws弹幕流数据中!,需要注意直播伴侣端提取的弹幕当前不会有该字段,除非在开播后打开浏览器访问一次你的直播间 3. MsgPack 现在添加了进程名字段`ProcessName`
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
@@ -20,6 +21,11 @@ namespace BarrageGrab
|
||||
/// </summary>
|
||||
public static WsBarrageService WssService { get; private set; } = new WsBarrageService();
|
||||
|
||||
/// <summary>
|
||||
/// 房间缓存信息
|
||||
/// </summary>
|
||||
public static RoomCacheManager RoomCaches { get; } = new RoomCacheManager();
|
||||
|
||||
/// <summary>
|
||||
/// 程序进程信息
|
||||
/// </summary>
|
||||
@@ -29,6 +35,81 @@ namespace BarrageGrab
|
||||
static AppRuntime()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 房间缓存管理器
|
||||
/// </summary>
|
||||
public class RoomCacheManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 房间ID - 房间信息映射缓存
|
||||
/// </summary>
|
||||
public ConcurrentDictionary<string, RoomInfo> RoomInfoCache { get; } = new ConcurrentDictionary<string, RoomInfo>();
|
||||
|
||||
/// <summary>
|
||||
/// 添加WebRoomid-房间ID 映射
|
||||
/// </summary>
|
||||
/// <param name="webrid"></param>
|
||||
/// <param name="roomid"></param>
|
||||
public void SetRoomCache(string roomid, string webrid)
|
||||
{
|
||||
if (RoomInfoCache.ContainsKey(roomid))
|
||||
{
|
||||
RoomInfoCache[roomid].WebRoomId = webrid;
|
||||
}
|
||||
else
|
||||
{
|
||||
RoomInfoCache.TryAdd(roomid, new RoomInfo()
|
||||
{
|
||||
RoomId = roomid,
|
||||
WebRoomId = webrid,
|
||||
Title = "房间" + webrid
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加房间缓存信息
|
||||
/// </summary>
|
||||
/// <param name="roomid"></param>
|
||||
/// <param name="roomInfo"></param>
|
||||
public void AddRoomInfoCache(RoomInfo roomInfo)
|
||||
{
|
||||
if (roomInfo == null) return;
|
||||
var roomid = roomInfo.RoomId;
|
||||
if (RoomInfoCache.ContainsKey(roomid))
|
||||
{
|
||||
RoomInfoCache[roomid] = roomInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
RoomInfoCache.TryAdd(roomid, roomInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据roomid从缓存获取webRoomid
|
||||
/// </summary>
|
||||
/// <param name="roomid"></param>
|
||||
/// <returns></returns>
|
||||
public long GetCachedWebRoomid(string roomid)
|
||||
{
|
||||
if (RoomInfoCache.TryGetValue(roomid, out var value)) return long.Parse(value.WebRoomId);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据roomid从缓存获取房间信息
|
||||
/// </summary>
|
||||
/// <param name="roomid"></param>
|
||||
/// <returns></returns>
|
||||
public RoomInfo GetCachedWebRoomInfo(string roomid)
|
||||
{
|
||||
if (RoomInfoCache.TryGetValue(roomid, out var value)) return value;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user