示例#1
0
 /// <summary>
 /// 执行OnSocketException
 /// </summary>
 private void ProcessSocketException(Socket handler, Exception e)
 {
     if (OnSocketException != null)
     {
         SocketSender sender = new SocketSender(handler);
         OnSocketException(new SocketExceptionArgs(sender, e));
     }
 }
示例#2
0
 /// <summary>
 /// 执行OnSocketReceive
 /// </summary>
 private void ProcessSocketReceive(Socket handler, string data)
 {
     if (OnSocketReceive != null)
     {
         SocketSender sender = new SocketSender(handler);
         OnSocketReceive(new SocketReceiveEventArgs(sender, data));
     }
 }
示例#3
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);
            }
        }
示例#4
0
 public SocketExceptionArgs(SocketSender sender, Exception exception)
 {
     this.Sender    = sender;
     this.Exception = exception;
 }
示例#5
0
        /// <summary>
        /// 发送消息
        /// </summary>
        /// <param name="message"></param>
        public void Send(string message)
        {
            SocketSender sender = new SocketSender(m_handler);

            sender.Send(message);
        }
 public SocketReceiveEventArgs(SocketSender sender, string content)
 {
     this.Sender  = sender;
     this.Content = content;
 }