protected void OnChouqinMessageRecieved(ChouqinMessage message) { if (ChouqinMessageRecieved != null) { ChouqinMessageRecieved(this, new MessageEventArgs <ChouqinMessage>(message)); } }
protected void OnChouqinMessageProcessed(ChouqinMessage message) { if (ChouqinMessageProcessed != null) { ChouqinMessageProcessed(this, new ProcessMessageEventArgs <ChouqinMessage>(message)); } }
void ProcessMessage(string messageText) { var type = messageText.Substring(0, messageText.IndexOf('/')); switch (type) { case "type@=chatmsg": ChatMessage chatMessage = new ChatMessage(messageText); ChatMessage.Save(chatMessage); OnChatMessageRecieved(chatMessage); break; case "type@=dgb": GiftMessage giftMessage = new GiftMessage(messageText); GiftMessage.Save(giftMessage); OnGiftMessageRecieved(giftMessage); break; case "type@=bc_buy_deserve": ChouqinMessage chouqinMessage = new ChouqinMessage(messageText); ChouqinMessage.Save(chouqinMessage); OnChouqinMessageRecieved(chouqinMessage); break; } }
void ProcessChouqinMessage(ChouqinMessage message) { try { // 酬勤赚积分 var chouqinScore = ScoreService.CalScore(message); UserService.AddScore(message.RoomId, message.UserId, message.UserName, chouqinScore); // 感谢 var userScore = UserService.GetScore(message.RoomId, message.UserId); Obs.ThanksMessage.AddMessage("感谢 {0} 送的 {1}, 总积分 {2}", message.UserName, message.ChouqinName, userScore); ChouqinMessage.SetProcessResult(message, ProcessResult.Ok);; OnChouqinMessageProcessed(message); } catch (Exception) { ChouqinMessage.SetProcessResult(message, ProcessResult.Error); throw; } }
public static double CalScore(ChouqinMessage chouqinMessage) { int score; switch (chouqinMessage.Level) { case 1: score = 36000; break; case 2: score = 75000; break; case 3: score = 130000; break; default: throw new DouyuException("该等级酬勤(Level {0})还未设定积分值!", chouqinMessage.Level); } return(score); }