Пример #1
0
        void ChatProtocol_Opened(object sender, EventArgs e)
        {
            if (!IsInited)
            {
                IsInited = true;
                this.InitRoom();
                this.Room.Partys.Add(this.customer);

                this.ChatJoin(null, this.UserID, string.Empty);

                // 缓存ChatParty
                ChatPartyCache.GetInstance().AddItem(this.customer);

                // 记录统计信息
                ChatPartyCache.GetInstance().LogCurrentPartyInfo();

                // 日志
                ChatLog.GetInstance().LogEvent(ChatEvent.NewClient
                                               , string.Format("Name:{0},SessionID:{1}", this.customer.DisplayName, this.SessionID));
            }
        }
Пример #2
0
        /// <summary>
        /// 离开聊天室
        /// </summary>
        public void LeftChat()
        {
            try
            {
                if (this.IsAvailableConnection)
                {
                    // 防止用户频繁刷新,导致坏死的Chat被接起
                    Thread.Sleep(500);

                    // 先发送一条离开的消息,解决Genesyslab不同版本无法解析退出的BUG
                    this.SendMessage(string.Format("[{0}] 已经离开。", this.Customer.DisplayName));
                    //this.SendMessage("网络异常,服务已中断。");
                    Thread.Sleep(50);
                    this.LeftChat(this.UserID, false);

                    // 从缓存移除
                    ChatPartyCache.GetInstance().RemoveParty(this.UserID);
                }
                this.PartyDispose(this.Customer);
            }
            catch { }
        }