Пример #1
0
        /// <summary>
        /// コメントと視聴人数などの情報を処理します。
        /// </summary>
        /// <param name="json"></param>
        private void HandleMessage(dynamic json)
        {
            try {
                String mode = json.mode;
                switch (mode)
                {
                case "get":
                    if (this.OnMessageList == null)
                    {
                        break;
                    }

                    var messages = this.ParseMessage(json);
                    this.OnMessageList(messages);
                    break;

                case "post":
                    if (this.OnNewMessage != null)
                    {
                        var post = new Message(json);
                        this.OnNewMessage(post);
                        break;
                    }
                    break;

                case "post_result":
                    if (this.OnPostResult != null)
                    {
                        var result = json.IsDefined("result") ? json.result : false;
                        this.OnPostResult(result);
                    }
                    break;

                case "ban_notify":
                    var banMessage = new Message(json);

                    if (banMessage.IsBan)
                    {
                        if (this.OnBan != null)
                        {
                            this.OnBan(banMessage);
                        }
                    }
                    else
                    {
                        if (this.OnUnBan != null)
                        {
                            this.OnUnBan(banMessage);
                        }
                    }
                    break;

                case "ban_fail":
                    if (this.OnBanFail != null)
                    {
                        var banFail = new BanFail(json);
                        this.OnBanFail(banFail);
                    }
                    break;

                case "show_id":
                    if (this.OnShowId != null)
                    {
                        var idNotify = new IdNotification(json);
                        this.OnShowId(idNotify);
                    }
                    break;

                case "hide_id":
                    if (this.OnHideId != null)
                    {
                        var idNotify = new IdNotification(json);
                        this.OnHideId(idNotify);
                    }
                    break;

                case "join":
                case "leave":
                    if (this.OnUpdateMember != null)
                    {
                        var ipCount = (Int32)json.ipcount;
                        if (this.OnUpdateMember != null)
                        {
                            this.OnUpdateMember(ipCount);
                        }
                    }
                    break;

                case "admin_yell":
                    if (this.OnAdminShout != null)
                    {
                        var adminShout = new AdminShout(json);
                        this.OnAdminShout(adminShout);
                    }
                    break;

                default:
                    break;
                }
            } catch (XmlException) {
                Debug.WriteLine("メッセージのParseに失敗しました。");
            } catch (RuntimeBinderException) {
                Debug.WriteLine("Json内にプロパティが見つかりませんでした。");
            }
        }
Пример #2
0
		private void HandleBanFail(dynamic json) {
			if (this.OnBanFail != null) {
				var banFail = new BanFail(json);
				this.OnBanFail(banFail);
			}
		}