弹幕数据附加主播自身信息

This commit is contained in:
Muihd
2024-04-26 00:55:47 +08:00
parent b29e36030d
commit 8ed6e17b8b
2 changed files with 65 additions and 1 deletions
@@ -102,6 +102,11 @@ namespace BarrageGrab.Modles.JsonEntity
/// </summary>
public MsgUser User { get; set; }
/// <summary>
/// 主播简要信息
/// </summary>
public RoomAnchorInfo Onwer { get; set; }
/// <summary>
/// 消息内容
/// </summary>
@@ -134,6 +139,37 @@ namespace BarrageGrab.Modles.JsonEntity
public int Level { get; set; }
}
/// <summary>
/// 直播间主播信息
/// </summary>
public class RoomAnchorInfo
{
/// <summary>
/// 用户ID
/// </summary>
public string UserId { get; set; }
/// <summary>
/// SecUid
/// </summary>
public string SecUid { get; set; }
/// <summary>
/// 昵称
/// </summary>
public string Nickname { get; set; }
/// <summary>
/// 头像地址
/// </summary>
public string HeadUrl { get; set; }
/// <summary>
/// 关注状态 0未关注,1已关注,...
/// </summary>
public int FollowStatus { get; set; }
}
/// <summary>
/// 用户弹幕信息
/// </summary>
+29 -1
View File
@@ -256,6 +256,25 @@ namespace BarrageGrab
OnPackMessage(this, arg);
}
//附加房间信息
private void AttachRoomInfo(Msg msg)
{
if(msg==null) return;
var roomInfo = AppRuntime.RoomCaches.GetCachedWebRoomInfo(msg.RoomId.ToString());
if (roomInfo != null)
{
msg.Onwer = new RoomAnchorInfo()
{
Nickname = roomInfo.Owner.Nickname,
HeadUrl = roomInfo.Owner.HeadUrl,
FollowStatus = roomInfo.Owner.FollowStatus,
SecUid = roomInfo.Owner.SecUid,
UserId = roomInfo.Owner.UserId
};
msg.WebRoomId = roomInfo.WebRoomId;
}
}
//粉丝团
private void Grab_OnFansclubMessage(object sender, WssBarrageGrab.RoomMessageEventArgs<FansclubMessage> e)
{
@@ -266,13 +285,14 @@ namespace BarrageGrab
MsgId = msg.Common.msgId,
Content = msg.Content,
RoomId = msg.Common.roomId,
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
WebRoomId = AppRuntime.RoomCaches.GetCachedWebRoomid(msg.Common.roomId.ToString()),
Type = msg.Type,
User = GetUser(msg.User)
};
enty.Level = enty.User.FansClub.Level;
var msgType = PackMsgType.粉丝团消息;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
Broadcast(new BarrageMsgPack(enty.ToJson(), msgType, e.Process));
@@ -297,6 +317,7 @@ namespace BarrageGrab
};
var msgType = PackMsgType.直播间统计;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -391,6 +412,7 @@ namespace BarrageGrab
}
var msgType = PackMsgType.礼物消息;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), PackMsgType.礼物消息, e.Process);
@@ -413,6 +435,7 @@ namespace BarrageGrab
};
var msgType = PackMsgType.关注消息;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -443,6 +466,7 @@ namespace BarrageGrab
};
var msgType = PackMsgType.直播间分享;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
@@ -469,6 +493,7 @@ namespace BarrageGrab
};
var msgType = PackMsgType.进直播间;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -494,6 +519,7 @@ namespace BarrageGrab
};
var msgType = PackMsgType.点赞消息;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
var pack = new BarrageMsgPack(enty.ToJson(), msgType, e.Process);
@@ -516,6 +542,7 @@ namespace BarrageGrab
};
var msgType = PackMsgType.弹幕消息;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
@@ -542,6 +569,7 @@ namespace BarrageGrab
};
var msgType = PackMsgType.下播;
AttachRoomInfo(enty);
FirePack(enty, msgType);
PrintMsg(enty, msgType);
pack = new BarrageMsgPack(enty.ToJson(), PackMsgType.下播, e.Process);