礼物数量不再连续推送,改为取每次增量,去除GroupCount改为GiftCount即同一组礼物下本次相较上次的礼物的增量
This commit is contained in:
@@ -177,17 +177,16 @@
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public string GiftName { get; set; }
|
public string GiftName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 本次(增量)礼物数量
|
||||||
|
/// </summary>
|
||||||
|
public long GiftCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 礼物数量(连续的)
|
/// 礼物数量(连续的)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long RepeatCount { get; set; }
|
public long RepeatCount { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 礼物数量(本次)
|
|
||||||
/// </summary>
|
|
||||||
public long GroupCount { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 抖币价格
|
/// 抖币价格
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -169,11 +169,14 @@ namespace BarrageGrab
|
|||||||
|
|
||||||
int lastCount = 0;
|
int lastCount = 0;
|
||||||
int currCount = (int)e.repeatCount;
|
int currCount = (int)e.repeatCount;
|
||||||
|
var backward = currCount <= lastCount;
|
||||||
|
if (currCount <= 0) currCount = 1;
|
||||||
|
|
||||||
if (giftCountCache.ContainsKey(key))
|
if (giftCountCache.ContainsKey(key))
|
||||||
{
|
{
|
||||||
lastCount = giftCountCache[key].Item1;
|
lastCount = giftCountCache[key].Item1;
|
||||||
if (currCount > lastCount)
|
backward = currCount <= lastCount;
|
||||||
|
if (!backward)
|
||||||
{
|
{
|
||||||
lock (giftCountCache)
|
lock (giftCountCache)
|
||||||
{
|
{
|
||||||
@@ -183,7 +186,7 @@ namespace BarrageGrab
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (e.groupId > 0)
|
if (e.groupId > 0 && !backward)
|
||||||
{
|
{
|
||||||
lock (giftCountCache)
|
lock (giftCountCache)
|
||||||
{
|
{
|
||||||
@@ -191,19 +194,20 @@ namespace BarrageGrab
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//比上次小,则说明先后顺序出了问题,直接丢掉,因为上次已经填充发送过了
|
//比上次小,则说明先后顺序出了问题,直接丢掉,应为比它大的消息已经处理过了
|
||||||
if (currCount < lastCount) return;
|
if (backward) return;
|
||||||
|
|
||||||
|
|
||||||
|
var count = currCount - lastCount;
|
||||||
|
|
||||||
for (int repeat = lastCount+1; repeat <= currCount; repeat++)
|
|
||||||
{
|
|
||||||
var enty = new GiftMsg()
|
var enty = new GiftMsg()
|
||||||
{
|
{
|
||||||
MsgId = e.Common.msgId+repeat,
|
MsgId = e.Common.msgId,
|
||||||
RoomId = e.Common.roomId,
|
RoomId = e.Common.roomId,
|
||||||
Content = $"{e.User.Nickname} 送出 {e.Gift.Name} x {repeat} 个",
|
Content = $"{e.User.Nickname} 送出 {e.Gift.Name} x {currCount} 个,增量{count}个",
|
||||||
DiamondCount = e.Gift.diamondCount,
|
DiamondCount = e.Gift.diamondCount,
|
||||||
RepeatCount = repeat,
|
RepeatCount = currCount,
|
||||||
GroupCount = e.groupCount,
|
GiftCount = count,
|
||||||
GiftId = e.giftId,
|
GiftId = e.giftId,
|
||||||
GiftName = e.Gift.Name,
|
GiftName = e.Gift.Name,
|
||||||
User = GetUser(e.User)
|
User = GetUser(e.User)
|
||||||
@@ -214,7 +218,6 @@ namespace BarrageGrab
|
|||||||
var json = JsonConvert.SerializeObject(pack);
|
var json = JsonConvert.SerializeObject(pack);
|
||||||
this.Broadcast(json);
|
this.Broadcast(json);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
//关注
|
//关注
|
||||||
private void Grab_OnSocialMessage(object sender, ProtoEntity.SocialMessage e)
|
private void Grab_OnSocialMessage(object sender, ProtoEntity.SocialMessage e)
|
||||||
|
|||||||
Reference in New Issue
Block a user