public void OnTimer() { if (m_lNext.Count <= 0) { return; } if (!m_pNext.IsTimeOut() && m_lLast.Count > 0) { return; } m_pNext.Update(); var bc = m_lNext[0]; m_pActive = bc; lock (m_pLock) { m_lLast.Add(bc); m_lNext.RemoveAt(0); } m_pAdLogRepo.SaveOrUpdate(new DbBroadcastLog { Addition = bc.Addition, Message = bc.Message, Time = (uint)UnixTimestamp.Timestamp(), UserIdentity = bc.OwnerIdentity, UserName = bc.OwnerName }); ServerKernel.SendMessageToAll(new MsgTalk(bc.Message, ChatTone.BROADCAST) { Sender = bc.OwnerName }); }
public bool Push(Character pRole, string szMessage, bool bShowError) { if (szMessage.Length > 80) { if (bShowError) { pRole.Send(ServerString.STR_PIGEON_SEND_ERR_STRING_TOOLONG); } return(false); } if (szMessage.Length <= 0) { if (bShowError) { pRole.Send(ServerString.STR_PIGEON_SEND_ERR_EMPTYSTRING); } return(false); } if (UserNextMessagesCount(pRole.Identity) >= 5) { if (bShowError) { pRole.Send(ServerString.STR_PIGEON_SEND_OVER_5_PIECES); } return(false); } if (pRole.Emoney < _PIGEON_PRICE) { if (bShowError) { pRole.Send(ServerString.STR_PIGEON_URGENT_ERR_NOEMONEY); } return(false); } if (!pRole.ReduceMoney(_PIGEON_PRICE)) { if (bShowError) { pRole.Send(ServerString.STR_PIGEON_URGENT_ERR_NOEMONEY); } return(false); } var newBc = new Broadcast { Identity = m_dwNext++, Message = szMessage, OwnerIdentity = pRole.Identity, OwnerName = pRole.Name }; lock (m_pLock) m_lNext.Add(newBc); //m_pAdQueueRepo.SaveOrUpdate(new DbBroadcastQueue //{ // NextIdentity = m_dwNext++, // UserIdentity = pRole.Identity, // Message = szMessage, // UserName = pRole.Name, // Time = (uint) UnixTimestamp.Timestamp() //}); pRole.Send(ServerString.STR_PIGEON_SEND_PIGEON_PRODUCE_PROMPT); return(true); }