From 8ed6e17b8b3b5f36bd2c309467de664741a5388a Mon Sep 17 00:00:00 2001 From: Muihd <1083092844@qq.com> Date: Fri, 26 Apr 2024 00:55:47 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=B9=E5=B9=95=E6=95=B0=E6=8D=AE=E9=99=84?= =?UTF-8?q?=E5=8A=A0=E4=B8=BB=E6=92=AD=E8=87=AA=E8=BA=AB=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Modles/JsonEntity/BarrageMessages.cs | 36 +++++++++++++++++++ BarrageGrab/WsBarrageServer.cs | 30 +++++++++++++++- 2 files changed, 65 insertions(+), 1 deletion(-) diff --git a/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs b/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs index 7ae4a19..2e1bb13 100644 --- a/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs +++ b/BarrageGrab/Modles/JsonEntity/BarrageMessages.cs @@ -102,6 +102,11 @@ namespace BarrageGrab.Modles.JsonEntity /// public MsgUser User { get; set; } + /// + /// 主播简要信息 + /// + public RoomAnchorInfo Onwer { get; set; } + /// /// 消息内容 /// @@ -134,6 +139,37 @@ namespace BarrageGrab.Modles.JsonEntity public int Level { get; set; } } + /// + /// 直播间主播信息 + /// + public class RoomAnchorInfo + { + /// + /// 用户ID + /// + public string UserId { get; set; } + + /// + /// SecUid + /// + public string SecUid { get; set; } + + /// + /// 昵称 + /// + public string Nickname { get; set; } + + /// + /// 头像地址 + /// + public string HeadUrl { get; set; } + + /// + /// 关注状态 0未关注,1已关注,... + /// + public int FollowStatus { get; set; } + } + /// /// 用户弹幕信息 /// diff --git a/BarrageGrab/WsBarrageServer.cs b/BarrageGrab/WsBarrageServer.cs index c9edddf..f1e0825 100644 --- a/BarrageGrab/WsBarrageServer.cs +++ b/BarrageGrab/WsBarrageServer.cs @@ -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 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);