@@ -36,38 +36,16 @@ public class MQTTServerBinding : ServerBinding<MQTTServerBinding>
3636 /// <summary>
3737 /// Interval in seconds the broker maintains a session
3838 /// for a disconnected client until this interval expires.
39+ /// Either an <see cref="MQTTInteger"/> or an <see cref="MQTTIntegerSchema"/>.
3940 /// </summary>
40- /// <remarks>
41- /// Returns null when the value is a schema or does not fit in an Int32 (MQTT allows up to 4294967295).
42- /// Use <see cref="SessionExpiryIntervalValue"/> to read every value.
43- /// </remarks>
44- [ Obsolete ( "Returns null for schema values and values above Int32.MaxValue. Use SessionExpiryIntervalValue instead." ) ]
45- public int ? SessionExpiryInterval
46- {
47- get => this . SessionExpiryIntervalValue ? . Integer ;
48- set => this . SessionExpiryIntervalValue = value . HasValue ? MQTTIntegerOrSchema . FromInteger ( value . Value ) : null ;
49- }
50-
51- /// <summary>The integer-or-schema session expiry interval value.</summary>
52- public MQTTIntegerOrSchema SessionExpiryIntervalValue { get ; set ; }
41+ public MQTTIntegerOrSchema SessionExpiryInterval { get ; set ; }
5342
5443 /// <summary>
5544 /// Number of bytes representing the maximum packet size
5645 /// the client is willing to accept.
46+ /// Either an <see cref="MQTTInteger"/> or an <see cref="MQTTIntegerSchema"/>.
5747 /// </summary>
58- /// <remarks>
59- /// Returns null when the value is a schema or does not fit in an Int32 (MQTT allows up to 4294967295).
60- /// Use <see cref="MaximumPacketSizeValue"/> to read every value.
61- /// </remarks>
62- [ Obsolete ( "Returns null for schema values and values above Int32.MaxValue. Use MaximumPacketSizeValue instead." ) ]
63- public int ? MaximumPacketSize
64- {
65- get => this . MaximumPacketSizeValue ? . Integer ;
66- set => this . MaximumPacketSizeValue = value . HasValue ? MQTTIntegerOrSchema . FromInteger ( value . Value ) : null ;
67- }
68-
69- /// <summary>The integer-or-schema maximum packet size value.</summary>
70- public MQTTIntegerOrSchema MaximumPacketSizeValue { get ; set ; }
48+ public MQTTIntegerOrSchema MaximumPacketSize { get ; set ; }
7149
7250 public override string BindingKey => "mqtt" ;
7351
@@ -78,8 +56,8 @@ public int? MaximumPacketSize
7856 { "cleanSession" , ( a , n ) => { a . CleanSession = n . GetBooleanValue ( ) ; } } ,
7957 { "lastWill" , ( a , n ) => { a . LastWill = n . ParseMap ( LastWillFixedFields ) ; } } ,
8058 { "keepAlive" , ( a , n ) => { a . KeepAlive = n . GetIntegerValue ( ) ; } } ,
81- { "sessionExpiryInterval" , ( a , n ) => { a . SessionExpiryIntervalValue = MQTTIntegerOrSchema . Parse ( n ) ; } } ,
82- { "maximumPacketSize" , ( a , n ) => { a . MaximumPacketSizeValue = MQTTIntegerOrSchema . Parse ( n ) ; } } ,
59+ { "sessionExpiryInterval" , ( a , n ) => { a . SessionExpiryInterval = MQTTIntegerOrSchema . Parse ( n ) ; } } ,
60+ { "maximumPacketSize" , ( a , n ) => { a . MaximumPacketSize = MQTTIntegerOrSchema . Parse ( n ) ; } } ,
8361 } ;
8462
8563 private static FixedFieldMap < LastWill > LastWillFixedFields = new ( )
@@ -136,8 +114,8 @@ private void SerializeProperties(IAsyncApiWriter writer, AsyncApiVersion version
136114 writer . WriteOptionalProperty ( "cleanSession" , this . CleanSession ) ;
137115 writer . WriteOptionalObject ( "lastWill" , this . LastWill , ( w , l ) => l . Serialize ( w ) ) ;
138116 writer . WriteOptionalProperty ( "keepAlive" , this . KeepAlive ) ;
139- this . WriteIntegerOrSchema ( writer , "sessionExpiryInterval" , this . SessionExpiryIntervalValue , version ) ;
140- this . WriteIntegerOrSchema ( writer , "maximumPacketSize" , this . MaximumPacketSizeValue , version ) ;
117+ this . WriteIntegerOrSchema ( writer , "sessionExpiryInterval" , this . SessionExpiryInterval , version ) ;
118+ this . WriteIntegerOrSchema ( writer , "maximumPacketSize" , this . MaximumPacketSize , version ) ;
141119 writer . WriteOptionalProperty ( AsyncApiConstants . BindingVersion , this . BindingVersion ) ;
142120 writer . WriteExtensions ( this . Extensions ) ;
143121 writer . WriteEndObject ( ) ;
@@ -153,12 +131,13 @@ private void SerializeProperties(IAsyncApiWriter writer, AsyncApiVersion version
153131 /// <exception cref="ArgumentNullException">A value is present and <paramref name="writer"/> or <paramref name="name"/> is null.</exception>
154132 private void WriteIntegerOrSchema ( IAsyncApiWriter writer , string name , MQTTIntegerOrSchema value , AsyncApiVersion version )
155133 {
156- if ( value ? . LongInteger is long integer ) writer . WriteRequiredProperty ( name , integer ) ;
157- else if ( value ? . Schema != null ) writer . WriteOptionalObject ( name , value . Schema , ( w , schema ) =>
134+ if ( value == null )
158135 {
159- if ( version == AsyncApiVersion . AsyncApi2_0 ) schema . SerializeV2 ( w ) ;
160- else schema . SerializeV3 ( w ) ;
161- } ) ;
136+ return ;
137+ }
138+
139+ writer . WritePropertyName ( name ) ;
140+ value . Serialize ( writer , version ) ;
162141 }
163142 }
164143}
0 commit comments