@@ -66,6 +66,8 @@ public Options()
6666 HeartbeatTimeout = - 1 ;
6767 HelloMsg = null ;
6868 CanSendHelloMsg = false ;
69+ DisconnectMsg = null ;
70+ CanGenerateDisconnectMsg = false ;
6971 Correlate = false ;
7072 Relaxed = false ;
7173 }
@@ -321,12 +323,23 @@ public byte IdentitySize {
321323 /// Hello msg to send to peer upon connecting
322324 /// </summary>
323325 public byte [ ] ? HelloMsg { get ; set ; }
324-
326+
327+
328+ /// <summary>
329+ /// Disconnect msg to send to peer upon disconnecting
330+ /// </summary>
331+ public byte [ ] ? DisconnectMsg { get ; set ; }
332+
325333 /// <summary>
326334 /// Indicate of socket can send an hello msg
327335 /// </summary>
328336 public bool CanSendHelloMsg { get ; set ; }
329337
338+ /// <summary>
339+ /// Indicate of socket can generate a disconnect msg
340+ /// </summary>
341+ public bool CanGenerateDisconnectMsg { get ; set ; }
342+
330343 public bool Correlate { get ; set ; }
331344 public bool Relaxed { get ; set ; }
332345
@@ -528,6 +541,27 @@ public void SetSocketOption(ZmqSocketOption option, object? optionValue)
528541 break ;
529542 }
530543
544+
545+ case ZmqSocketOption . DisconnectMessage :
546+ {
547+ if ( optionValue == null )
548+ {
549+ DisconnectMsg = null ;
550+ }
551+ else if ( CanGenerateDisconnectMsg )
552+ {
553+ var disconnectMsg = Get < byte [ ] > ( ) ;
554+ DisconnectMsg = new byte [ disconnectMsg . Length ] ;
555+
556+ Buffer . BlockCopy ( disconnectMsg , 0 , DisconnectMsg , 0 , disconnectMsg . Length ) ;
557+ }
558+ else
559+ {
560+ throw new InvalidException ( "Socket doesn't support disconnect message" ) ;
561+ }
562+ break ;
563+ }
564+
531565 case ZmqSocketOption . Relaxed :
532566 {
533567 Relaxed = Get < bool > ( ) ;
0 commit comments