コード例 #1
0
        /// <summary>
        /// 向所有的客户端广播消息
        /// </summary>
        public void Broadcast(string message)
        {
            if (m_handlerList == null)
            {
                return;
            }

            if (m_handlerList.Count <= 0)
            {
                return;
            }

            //遍历客户端列表并发送消息
            foreach (Socket handler in m_handlerList)
            {
                SocketSender sender = new SocketSender(handler);
                sender.Send(message);
            }
        }
コード例 #2
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="message"></param>
        public void Send(string message)
        {
            SocketSender sender = new SocketSender(m_handler);

            sender.Send(message);
        }