public int CheckEnableChat(long accountId, string accountName, string message, int userType, out ChatMessage msg) { ChatUser user; msg = null; if (_users.TryGetValue(accountId, out user)) { //if (user.TotalRecentBetting < _chatGoldLimit) // return -1; if (ChatFilter.CheckBanned(accountName)) { return(-2); } if (TimeSpan.FromTicks(DateTime.Now.Ticks - user.LastSpamTime).TotalMinutes <= 5) { return(-3); } if (user.DetectSpam(message)) { return(-4); } } else { //long recentBetting = Lddb.Instance.GetRecentBetting(accountId); //if (recentBetting < 0) // return -1; user = new ChatUser { AccountId = accountId, AccountName = accountName, //TotalRecentBetting = recentBetting, LastActiveTime = DateTime.Now.Ticks, }; _users.AddOrUpdate(accountId, user, (k, v) => v = user); //if (recentBetting < _chatGoldLimit) // return -1; if (ChatFilter.CheckBanned(accountName)) { return(-2); } if (TimeSpan.FromTicks(DateTime.Now.Ticks - user.LastSpamTime).TotalMinutes <= 5) { return(-3); } if (user.DetectSpam(message)) { return(-4); } } int uType = 4; if (userType >= 3) { uType = 3; } if (Monitor.TryEnter(_lockmsg, 5000)) { try { msg = new ChatMessage { T = uType, M = message, U = accountName }; _msgs.Add(msg); if (_msgs.Count > 100) { _msgs.RemoveAt(0); } } finally { Monitor.Exit(_lockmsg); } } return(0); }