Esempio n. 1
0
        public bool Receive(string sessionId, ResponsesListener listener)
        {
            AccountSession session = null;
            bool           flag    = false;

            lock (this)
            {
                if (!this.m_Sessions.ContainsKey(sessionId))
                {
                    this.m_Sessions[sessionId] = new AccountSession(this.m_User, sessionId);
                    flag = true;
                }
                this.m_LastAccessTime = DateTime.Now;
                session = this.m_Sessions[sessionId] as AccountSession;
            }
            if (flag)
            {
                ServerImpl.Instance.WriteLog(string.Format("Reset Session:SessionID = \"{0}\", UserName='******'", sessionId, this.m_User));
                session.Send("GLOBAL:SessionReset", "null");
            }
            if (session != null)
            {
                SessionManagement.Instance.Insert(session);
            }
            return(session.Receive(listener));
        }
Esempio n. 2
0
        private void SendUnreadMessage(AccountSession session)
        {
            DateTime     lastAccessTime;
            AccountState state;
            AccountState state2;

            lock ((state2 = state = this))
            {
                lastAccessTime = (DateTime)this.GetConfig("MESSAGE.CONF")["LastReceivedTime"];
                if (lastAccessTime > this.m_LastAccessTime)
                {
                    lastAccessTime = this.m_LastAccessTime;
                }
            }
            List <Message> list = MessageImpl.Instance.Find(this.m_User, "*", new DateTime?(lastAccessTime));
            string         data = string.Empty;

            if (list.Count > 0)
            {
                data = Utility.RenderHashJson(new object[] { "Peer", "*", "Messages", list });
                Hashtable config = this.GetConfig("MESSAGE.CONF");
                lock (config)
                {
                    foreach (Message message in list)
                    {
                        DateTime time2 = (DateTime)config["LastReceivedTime"];
                        if (time2 < message.CreatedTime)
                        {
                            config["LastReceivedTime"] = message.CreatedTime;
                        }
                    }
                }
                lock ((state2 = state = this))
                {
                    this.SaveConfig();
                }
            }
            else
            {
                data = Utility.RenderHashJson(new object[] { "Peer", "*", "Messages", JsonText.EmptyArray });
            }
            session.Send("GLOBAL:IM_MESSAGE_NOTIFY", data);
        }
Esempio n. 3
0
        private void SendUnreadMessage(AccountSession session)
        {
            try
            {
                if (m_UserID == AccountImpl.AdminID)
                {
                    return;
                }

                DateTime from;
                lock (this)
                {
                    from = m_LastAccessTime;
                }

                List <Message> msgs = MessageImpl.Instance.Find(m_UserID, 0, from);
                string         data = String.Empty;

                if (msgs.Count > 0)
                {
                    data = Utility.RenderHashJson(
                        "Peer", 0,
                        "Messages", msgs,
                        "Users", Utility.GetRelUsers(msgs)
                        );
                    AccountInfo userInfo = AccountImpl.Instance.GetUserInfo(m_UserID);
                }
                else
                {
                    data = Utility.RenderHashJson(
                        "Peer", 0,
                        "Messages", JsonText.EmptyArray,
                        "Users", JsonText.EmptyObject
                        );
                }

                session.Send("GLOBAL:IM_MESSAGE_NOTIFY", data);
            }
            catch
            {
            }
        }