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)