NetMQSocketEventArgs.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using System;
  2. namespace NetMQ
  3. {
  4. /// <summary>
  5. /// This subclass of EventArgs contains a NetMQSocket,
  6. /// and IsReadyToReceive and IsReadyToSend flags to indicate whether ready to receive or send.
  7. /// </summary>
  8. public class NetMQSocketEventArgs : EventArgs
  9. {
  10. /// <summary>
  11. /// Create a new NetMQSocketEventArgs referencing the given socket.
  12. /// </summary>
  13. /// <param name="socket">the NetMQSocket that this is in reference to</param>
  14. public NetMQSocketEventArgs(NetMQSocket socket)
  15. {
  16. Socket = socket;
  17. }
  18. /// <summary>
  19. /// Initialise the ReceiveReady and SendReady flags from the given PollEvents value.
  20. /// </summary>
  21. /// <param name="events">a PollEvents value that indicates whether the socket is ready to send or receive without blocking</param>
  22. internal void Init(PollEvents events)
  23. {
  24. IsReadyToReceive = events.HasIn();
  25. IsReadyToSend = events.HasOut();
  26. }
  27. /// <summary>
  28. /// Get the NetMQSocket that this references.
  29. /// </summary>
  30. public NetMQSocket Socket { get; }
  31. /// <summary>
  32. /// Get whether at least one message may be received by the socket without blocking.
  33. /// </summary>
  34. public bool IsReadyToReceive { get; private set; }
  35. /// <summary>
  36. /// Get whether at least one message may be sent by the socket without blocking.
  37. /// </summary>
  38. public bool IsReadyToSend { get; private set; }
  39. }
  40. }