Ejemplo n.º 1
0
        public static double CalScore(GiftMessage giftMessage)
        {
            var experience = giftMessage.GiftExperience;

            if (experience >= 20000)
            {
                experience *= 333;
            }
            else if (experience >= 5000)
            {
                experience *= 300;
            }
            else if (experience >= 1000)
            {
                experience *= 280;
            }
            else if (experience >= 60)
            {
                experience *= 250;
            }
            else if (experience >= 2)
            {
                experience *= 200;
            }
            else
            {
                experience *= 100;
            }
            return(experience);
        }
 protected void OnGiftMessageRecieved(GiftMessage giftMessage)
 {
     if (GiftMessageRecieved != null)
     {
         GiftMessageRecieved(this, new MessageEventArgs <GiftMessage>(giftMessage));
     }
 }
        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;
            }
        }
Ejemplo n.º 4
0
 protected void OnGiftMessageProcessed(GiftMessage message)
 {
     if (GiftMessageProcessed != null)
     {
         GiftMessageProcessed(this, new ProcessMessageEventArgs <GiftMessage>(message));
     }
 }
Ejemplo n.º 5
0
 public async Task GiftMessageHandlerAsync(GiftMessage giftMessage)
 {
     //如果礼物不是辣条
     if (giftMessage.GiftId != 1)
     {
         Console.WriteLine($"{giftMessage.Username}送出了{giftMessage.GiftNum}个{giftMessage.GiftName},价值:{giftMessage.TotalCoin}个{giftMessage.CoinType}");
     }
 }
Ejemplo n.º 6
0
 public void LiveGiftHandler(GiftMessage gift)
 {
     try
     {
         for (int i = 0; i < gift.Count; i++)
         {
             Vector3   offset    = new Vector3(Random.Range(-2f, 2f), Random.Range(1, 10), 0);
             Rigidbody newObject = Instantiate(Object, transform.position + offset, transform.rotation) as Rigidbody;
             Destroy(newObject.gameObject, 50);
         }
     }
     catch (Exception e)
     {
         Debug.Log(e);
         throw;
     }
 }
Ejemplo n.º 7
0
        void ProcessGiftMessage(GiftMessage message)
        {
            try {
                // 送礼物, 赚积分
                var giftScore = ScoreService.CalScore(message);
                UserService.AddScore(message.RoomId, message.UserId, message.UserName, giftScore);

                // 感谢
                var userScore = UserService.GetScore(message.RoomId, message.UserId);
                Obs.ThanksMessage.AddMessage("感谢 {0} 送的 {1}, 总积分 {2}",
                                             message.UserName, message.GiftName, userScore);

                GiftMessage.SetProcessResult(message, ProcessResult.Ok);
                OnGiftMessageProcessed(message);
            } catch (Exception) {
                GiftMessage.SetProcessResult(message, ProcessResult.Error);
                throw;
            }
        }
Ejemplo n.º 8
0
        public async Task DispatchAsync(JObject message, IMessageHandler messageHandler)
        {
            try
            {
                switch (message["cmd"].ToString())
                {
                case "DANMU_MSG":
                    await messageHandler.DanmuMessageHandlerAsync(DanmuMessage.JsonToDanmuMessage(message));

                    break;

                case "SEND_GIFT":
                    await messageHandler.GiftMessageHandlerAsync(GiftMessage.JsonToGiftMessage(message));

                    break;

                case "GUARD_MSG":     // TODO 上舰信息未处理(第一次购买)
                    Debug.WriteLine("上舰信息");
                    Debug.WriteLine(message);
                    break;

                case "GUARD_BUY":
                    await messageHandler.GuardBuyMessageHandlerAsync(GuardBuyMessage.JsonToGuardBuyMessage(message));

                    break;

                case "USER_TOAST_MSG":
                    await messageHandler.UserToastMessageHandlerAsync(UserToastMessage.JsonToUserToastMessage(message));

                    break;

                case "GUARD_LOTTERY_START":     // TODO 上舰抽奖通知
                    Debug.WriteLine("购买舰长后出现的抽奖");
                    Debug.WriteLine(message);
                    break;

                case "NOTICE_MSG":     // TODO 通知信息未处理
                    Debug.WriteLine(message);
                    Debug.WriteLine(message);
                    break;

                case "WELCOME":
                    await messageHandler.WelcomeMessageHandlerAsync(WelcomeMessage.JsonToWelcomeMessage(message));

                    break;

                case "SYS_MSG":     // TODO 系统消息未处理
                    Debug.WriteLine("SYS_MSG");
                    Debug.WriteLine(message);
                    break;

                case "COMBO_END":
                    await messageHandler.ComboEndMessageHandlerAsync(ComboEndMessage.JsonToComboEndMessage(message));

                    break;

                case "SUPER_CHAT_MESSAGE":     // TODO 醒目留言信息未处理
                    break;

                case "ROOM_REAL_TIME_MESSAGE_UPDATE":
                    await messageHandler.RoomUpdateMessageHandlerAsync(RoomUpdateMessage.JsonToRoomUpdateMessage(message));

                    break;

                case "SUPER_CHAT_MESSAGE_JPN":     // TODO 另一种醒目留言信息未处理
                    break;

                case "WELCOME_GUARD":
                    await messageHandler.WelcomeGuardMessageHandlerAsync(WelcomeGuardMessage.JsonToWelcomeGuardMessage(message));

                    break;

                case "ROOM_RANK":     // TODO 房间排行信息未处理
                    break;

                case "ENTRY_EFFECT":     // TODO 貌似是舰长的进入信息
                    await messageHandler.EntryEffectMessageHandlerAsync(EntryEffectMessage.JsonToEntryEffectMessage(message));

                    break;

                case "COMBO_SEND":     // TODO COMBO_SEND
                    await messageHandler.ComboEndMessageHandlerAsync(ComboEndMessage.JsonToComboEndMessage(message));

                    break;

                case "ANCHOR_LOT_START":     // TODO 天选时刻
                    Debug.WriteLine("ANCHOR_LOT_START");
                    Debug.WriteLine(message);
                    break;

                case "ACTIVITY_BANNER_UPDATE_V2":
                    Debug.WriteLine("ACTIVITY_BANNER_UPDATE_V2");
                    Debug.WriteLine(message);
                    break;

                case "ROOM_CHANGE":     //
                    Debug.WriteLine("ROOM_CHANGE");
                    Debug.WriteLine(message);
                    break;

                case "WEEK_STAR_CLOCK":
                    Debug.WriteLine("WEEK_STAR_CLOCK");
                    Debug.WriteLine(message);
                    break;

                case "LIVE":
                    await messageHandler.LiveStartMessageHandlerAsync(int.Parse(message["roomid"].ToString()));

                    break;

                case "PREPARING":
                    await messageHandler.LiveStopMessageHandlerAsync(int.Parse(message["roomid"].ToString()));

                    break;

                case "INTERACT_WORD":
                    await messageHandler.InteractWordMessageHandlerAsync(InteractWordMessage.JsonToInteractWordMessage(message));

                    break;

                case "ONLINERANK":     //更新排行榜信息
                    Debug.WriteLine("ONLINERANK");
                    Debug.WriteLine(message);
                    break;

                case "PANEL":     //更新分区排行等信息
                    Debug.WriteLine("PANEL");
                    Debug.WriteLine(message);
                    break;

                case "ROOM_BANNER":
                    Debug.WriteLine("ROOM_BANNER");
                    Debug.WriteLine(message);
                    break;

                default:
                    Debug.WriteLine("未记录的信息");
                    Debug.WriteLine(message);
                    break;
                }
            }
            catch (ArgumentException e)
            {
                Debug.WriteLine(e);
                throw;
            }
        }
Ejemplo n.º 9
0
 private void HandleEvent(GiftMessage gift)
 {
     Debug.Log($"[Gift received] {gift.Username}: {gift.Count} * {gift.Name}");
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AddressesAreIdentical != null)
         {
             hashCode = hashCode * 59 + AddressesAreIdentical.GetHashCode();
         }
         if (BlackListData != null)
         {
             hashCode = hashCode * 59 + BlackListData.GetHashCode();
         }
         if (CardOwnerAddress != null)
         {
             hashCode = hashCode * 59 + CardOwnerAddress.GetHashCode();
         }
         if (CustomerIpAddress != null)
         {
             hashCode = hashCode * 59 + CustomerIpAddress.GetHashCode();
         }
         if (DefaultFormFill != null)
         {
             hashCode = hashCode * 59 + DefaultFormFill.GetHashCode();
         }
         if (DeviceFingerprintActivated != null)
         {
             hashCode = hashCode * 59 + DeviceFingerprintActivated.GetHashCode();
         }
         if (DeviceFingerprintTransactionId != null)
         {
             hashCode = hashCode * 59 + DeviceFingerprintTransactionId.GetHashCode();
         }
         if (GiftCardType != null)
         {
             hashCode = hashCode * 59 + GiftCardType.GetHashCode();
         }
         if (GiftMessage != null)
         {
             hashCode = hashCode * 59 + GiftMessage.GetHashCode();
         }
         if (HasForgottenPwd != null)
         {
             hashCode = hashCode * 59 + HasForgottenPwd.GetHashCode();
         }
         if (HasPassword != null)
         {
             hashCode = hashCode * 59 + HasPassword.GetHashCode();
         }
         if (IsPreviousCustomer != null)
         {
             hashCode = hashCode * 59 + IsPreviousCustomer.GetHashCode();
         }
         if (OrderTimezone != null)
         {
             hashCode = hashCode * 59 + OrderTimezone.GetHashCode();
         }
         if (ShipComments != null)
         {
             hashCode = hashCode * 59 + ShipComments.GetHashCode();
         }
         if (ShipmentTrackingNumber != null)
         {
             hashCode = hashCode * 59 + ShipmentTrackingNumber.GetHashCode();
         }
         if (ShippingDetails != null)
         {
             hashCode = hashCode * 59 + ShippingDetails.GetHashCode();
         }
         if (UserData != null)
         {
             hashCode = hashCode * 59 + UserData.GetHashCode();
         }
         if (Website != null)
         {
             hashCode = hashCode * 59 + Website.GetHashCode();
         }
         return(hashCode);
     }
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Returns true if FraudFields instances are equal
        /// </summary>
        /// <param name="other">Instance of FraudFields to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(FraudFields other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AddressesAreIdentical == other.AddressesAreIdentical ||
                     AddressesAreIdentical != null &&
                     AddressesAreIdentical.Equals(other.AddressesAreIdentical)
                     ) &&
                 (
                     BlackListData == other.BlackListData ||
                     BlackListData != null &&
                     BlackListData.Equals(other.BlackListData)
                 ) &&
                 (
                     CardOwnerAddress == other.CardOwnerAddress ||
                     CardOwnerAddress != null &&
                     CardOwnerAddress.Equals(other.CardOwnerAddress)
                 ) &&
                 (
                     CustomerIpAddress == other.CustomerIpAddress ||
                     CustomerIpAddress != null &&
                     CustomerIpAddress.Equals(other.CustomerIpAddress)
                 ) &&
                 (
                     DefaultFormFill == other.DefaultFormFill ||
                     DefaultFormFill != null &&
                     DefaultFormFill.Equals(other.DefaultFormFill)
                 ) &&
                 (
                     DeviceFingerprintActivated == other.DeviceFingerprintActivated ||
                     DeviceFingerprintActivated != null &&
                     DeviceFingerprintActivated.Equals(other.DeviceFingerprintActivated)
                 ) &&
                 (
                     DeviceFingerprintTransactionId == other.DeviceFingerprintTransactionId ||
                     DeviceFingerprintTransactionId != null &&
                     DeviceFingerprintTransactionId.Equals(other.DeviceFingerprintTransactionId)
                 ) &&
                 (
                     GiftCardType == other.GiftCardType ||
                     GiftCardType != null &&
                     GiftCardType.Equals(other.GiftCardType)
                 ) &&
                 (
                     GiftMessage == other.GiftMessage ||
                     GiftMessage != null &&
                     GiftMessage.Equals(other.GiftMessage)
                 ) &&
                 (
                     HasForgottenPwd == other.HasForgottenPwd ||
                     HasForgottenPwd != null &&
                     HasForgottenPwd.Equals(other.HasForgottenPwd)
                 ) &&
                 (
                     HasPassword == other.HasPassword ||
                     HasPassword != null &&
                     HasPassword.Equals(other.HasPassword)
                 ) &&
                 (
                     IsPreviousCustomer == other.IsPreviousCustomer ||
                     IsPreviousCustomer != null &&
                     IsPreviousCustomer.Equals(other.IsPreviousCustomer)
                 ) &&
                 (
                     OrderTimezone == other.OrderTimezone ||
                     OrderTimezone != null &&
                     OrderTimezone.Equals(other.OrderTimezone)
                 ) &&
                 (
                     ShipComments == other.ShipComments ||
                     ShipComments != null &&
                     ShipComments.Equals(other.ShipComments)
                 ) &&
                 (
                     ShipmentTrackingNumber == other.ShipmentTrackingNumber ||
                     ShipmentTrackingNumber != null &&
                     ShipmentTrackingNumber.Equals(other.ShipmentTrackingNumber)
                 ) &&
                 (
                     ShippingDetails == other.ShippingDetails ||
                     ShippingDetails != null &&
                     ShippingDetails.Equals(other.ShippingDetails)
                 ) &&
                 (
                     UserData == other.UserData ||
                     UserData != null &&
                     UserData.SequenceEqual(other.UserData)
                 ) &&
                 (
                     Website == other.Website ||
                     Website != null &&
                     Website.Equals(other.Website)
                 ));
        }