/// <summary> /// 执行OnSocketException /// </summary> private void ProcessSocketException(Socket handler, Exception e) { if (OnSocketException != null) { SocketSender sender = new SocketSender(handler); OnSocketException(new SocketExceptionArgs(sender, e)); } }
/// <summary> /// 执行OnSocketReceive /// </summary> private void ProcessSocketReceive(Socket handler, string data) { if (OnSocketReceive != null) { SocketSender sender = new SocketSender(handler); OnSocketReceive(new SocketReceiveEventArgs(sender, data)); } }
/// <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); } }
public SocketExceptionArgs(SocketSender sender, Exception exception) { this.Sender = sender; this.Exception = exception; }
/// <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; }