예제 #1
0
        /// <summary>
        /// 向所有会话对象推送消息
        /// </summary>
        /// <param name="command">命令</param>
        /// <param name="msg">数据包</param>
        public static void SendToAll(SocketCommand command, string msg)
        {
            CustomServer server = SocketServiceObject.SocketService;

            if (server != null && server.SessionCount > 0)
            {
                IEnumerable <CustomSession> allSessions = server.GetAllSessions();
                foreach (CustomSession session in allSessions)
                {
                    if (session != null && session.Connected)
                    {
                        session.Send(command, msg);
                    }
                }
            }
        }