Esempio n. 1
0
        /// <summary>获取统计信息</summary>
        /// <param name="socket"></param>
        /// <returns></returns>
        public static String GetStat(this ISocketServer socket)
        {
            if (socket == null)
            {
                return(null);
            }

            var sb = new StringBuilder();

            //sb.AppendFormat("在线:{0:n0}/{1:n0} ", socket.SessionCount, socket.MaxSessionCount);
            if (socket.StatSend.Value > 0)
            {
                sb.AppendFormat("发送:{0} ", socket.StatSend);
            }
            if (socket.StatReceive.Value > 0)
            {
                sb.AppendFormat("接收:{0} ", SocketRemoteHelper.GetNetwork(socket.StatReceive));
            }
            if (socket.StatSession.Value > 0)
            {
                sb.AppendFormat("会话:{0} ", SocketRemoteHelper.GetNetwork(socket.StatSession));
            }

            return(sb.ToString());
        }
Esempio n. 2
0
        /// <summary>获取统计信息</summary>
        /// <returns></returns>
        public String GetStat()
        {
            var sb = new StringBuilder();

            if (MaxSessionCount > 0)
            {
                sb.AppendFormat("在线:{0:n0}/{1:n0} ", SessionCount, MaxSessionCount);
            }
            if (StatSend.Value > 0)
            {
                sb.AppendFormat("发送:{0} ", SocketRemoteHelper.GetNetwork(StatSend));
            }
            if (StatReceive.Value > 0)
            {
                sb.AppendFormat("接收:{0} ", SocketRemoteHelper.GetNetwork(StatReceive));
            }
            //if (StatSession.Value > 0) sb.AppendFormat("会话:{0} ", StatSession);

            return(sb.ToString());
        }