Example #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));
     }
 }
Example #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));
     }
 }
Example #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);
            }
        }
Example #4
0
 public SocketExceptionArgs(SocketSender sender, Exception exception)
 {
     this.Sender    = sender;
     this.Exception = exception;
 }
Example #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;
 }