File tree Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Expand file tree Collapse file tree 2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,13 @@ pub enum ClientMessage {
55
55
/// Initial message
56
56
initial_message : String ,
57
57
} ,
58
+ /// Negentropy Message
59
+ NegMsg {
60
+ /// Subscription ID
61
+ subscription_id : SubscriptionId ,
62
+ /// Message
63
+ message : String ,
64
+ } ,
58
65
}
59
66
60
67
impl Serialize for ClientMessage {
@@ -175,6 +182,10 @@ impl ClientMessage {
175
182
initial_message
176
183
] )
177
184
}
185
+ Self :: NegMsg {
186
+ subscription_id,
187
+ message,
188
+ } => json ! ( [ "NEG-MSG" , subscription_id, message] ) ,
178
189
}
179
190
}
180
191
@@ -288,6 +299,20 @@ impl ClientMessage {
288
299
} ) ;
289
300
}
290
301
302
+ // Negentropy Message
303
+ // ["NEG-MSG", <subscription ID string>, <message, lowercase hex-encoded>]
304
+ if v[ 0 ] == "NEG-MSG" {
305
+ if v_len != 3 {
306
+ return Err ( MessageHandleError :: InvalidMessageFormat ) ;
307
+ }
308
+ let subscription_id: SubscriptionId = SubscriptionId :: new ( v[ 1 ] . to_string ( ) ) ;
309
+ let message: String = v[ 2 ] . to_string ( ) ;
310
+ return Ok ( Self :: NegMsg {
311
+ subscription_id,
312
+ message,
313
+ } ) ;
314
+ }
315
+
291
316
Err ( MessageHandleError :: InvalidMessageFormat )
292
317
}
293
318
Original file line number Diff line number Diff line change @@ -56,6 +56,13 @@ pub enum RelayMessage {
56
56
/// Events count
57
57
count : usize ,
58
58
} ,
59
+ /// Negentropy Message
60
+ NegMsg {
61
+ /// Subscription ID
62
+ subscription_id : SubscriptionId ,
63
+ /// Message
64
+ message : String ,
65
+ } ,
59
66
}
60
67
61
68
impl Serialize for RelayMessage {
@@ -153,6 +160,10 @@ impl RelayMessage {
153
160
subscription_id,
154
161
count,
155
162
} => json ! ( [ "COUNT" , subscription_id, { "count" : count } ] ) ,
163
+ Self :: NegMsg {
164
+ subscription_id,
165
+ message,
166
+ } => json ! ( [ "NEG-MSG" , subscription_id, message] ) ,
156
167
}
157
168
}
158
169
@@ -266,6 +277,20 @@ impl RelayMessage {
266
277
return Ok ( Self :: new_count ( subscription_id, count) ) ;
267
278
}
268
279
280
+ // Negentropy Message
281
+ // ["NEG-MSG", <subscription ID string>, <message, lowercase hex-encoded>]
282
+ if v[ 0 ] == "NEG-MSG" {
283
+ if v_len != 3 {
284
+ return Err ( MessageHandleError :: InvalidMessageFormat ) ;
285
+ }
286
+ let subscription_id: SubscriptionId = SubscriptionId :: new ( v[ 1 ] . to_string ( ) ) ;
287
+ let message: String = v[ 2 ] . to_string ( ) ;
288
+ return Ok ( Self :: NegMsg {
289
+ subscription_id,
290
+ message,
291
+ } ) ;
292
+ }
293
+
269
294
Err ( MessageHandleError :: InvalidMessageFormat )
270
295
}
271
296
You can’t perform that action at this time.
0 commit comments