示例#1
0
        protected override void OnHandShaked()
        {
            base.OnHandShaked();

            if (AppServer.SessionCount <= 1)
            {
                return;
            }

            foreach (var x in AppServer.GetSessions(s => !s.SessionID.Equals(this.SessionID)))
            {
                x.SendJsonResponse("NEW", this.SessionID);
            }
        }
示例#2
0
        /// <summary>
        /// 提醒上线
        /// </summary>
        /// <param name="sessionId"></param>
        /// <param name="userName"></param>
        internal void NotifyOnline(string sessionId, string userName)
        {
            var ss = AppServer.GetSessions(o => !o.SessionID.Equals(sessionId));

            ss.AsParallel().ForAll(s =>
            {
                var json = new JsonDict();
                json.Add("SessionID", sessionId);
                json.Add("UserName", userName);
                json.Add("Msg", string.Format("{0} 客户端上线", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")));
                ArraySegmentWrapper segmentWrapper = new ArraySegmentWrapper(Constants.NOTIFY_ONLINE_RESPONSE_KEY, json.ToBytes());

                this.SendData(s, segmentWrapper.Wrapper());
            });
        }