From 4cca3e221265cae5538660517a2d02e90944ea1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E7=99=BD=E7=8C=BF?= <1083092844@qq.com> Date: Sat, 1 Apr 2023 00:09:07 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=87=E6=BB=A4=E4=B8=8D=E5=90=8C=E5=BC=B9?= =?UTF-8?q?=E5=B9=95=E7=B1=BB=E5=9E=8B=E4=B8=8B=EF=BC=8C=E5=8D=83=E6=9D=A1?= =?UTF-8?q?=E5=86=85=E9=87=8D=E5=A4=8D=E5=BC=B9=E5=B9=95ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BarrageGrab/WssBarrageGrab.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/BarrageGrab/WssBarrageGrab.cs b/BarrageGrab/WssBarrageGrab.cs index fbb77dc..e59e42a 100644 --- a/BarrageGrab/WssBarrageGrab.cs +++ b/BarrageGrab/WssBarrageGrab.cs @@ -146,11 +146,30 @@ namespace BarrageGrab catch (Exception) { } } - + //用于缓存接收过的消息ID,判断是否重复接收 + Dictionary> msgDic = new Dictionary>(); //发送事件 private void DoMessage(Message msg) - { + { + List msgIdList; + if (msgDic.ContainsKey(msg.Method)) + { + msgIdList = msgDic[msg.Method]; + } + else + { + msgIdList = new List(1000); + msgDic.Add(msg.Method, msgIdList); + } + if (msgIdList.Contains(msg.msgId)) + { + return; + } + + msgIdList.Add(msg.msgId); + if (msgIdList.Count > 990) msgIdList.RemoveAt(0); + try { switch (msg.Method)