Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
parity
Mirrored projects
jsonrpsee
Commits
5d214419
Unverified
Commit
5d214419
authored
Jun 27, 2022
by
Alexandru Vasile
Browse files
Maybe accept the subscription
Signed-off-by:
Alexandru Vasile
<
alexandru.vasile@parity.io
>
parent
15f18c01
Changes
1
Show whitespace changes
Inline
Side-by-side
core/src/server/rpc_module.rs
View file @
5d214419
...
...
@@ -1009,7 +1009,7 @@ impl SubscriptionSink {
/// Attempt to accept the subscription and respond the subscription method call.
///
/// Fails if the connection was closed
/// Fails if the connection was closed
, or if called multiple times.
pub
fn
accept
(
&
mut
self
)
->
Result
<
(),
SubscriptionEmptyError
>
{
let
id
=
self
.id
.take
()
.ok_or
(
SubscriptionEmptyError
)
?
;
...
...
@@ -1023,6 +1023,11 @@ impl SubscriptionSink {
}
}
/// Accepts the subscription if previously not accepted.
fn
maybe_accept
(
&
mut
self
)
{
let
_
=
self
.accept
();
}
/// Send a message back to subscribers.
///
/// Returns `Ok(true)` if the message could be send
...
...
@@ -1030,6 +1035,8 @@ impl SubscriptionSink {
/// Return `Err(err)` if the message could not be serialized.
///
pub
fn
send
<
T
:
Serialize
>
(
&
mut
self
,
result
:
&
T
)
->
Result
<
bool
,
serde_json
::
Error
>
{
self
.maybe_accept
();
// only possible to trigger when the connection is dropped.
if
self
.is_closed
()
{
return
Ok
(
false
);
...
...
@@ -1083,6 +1090,8 @@ impl SubscriptionSink {
T
:
Serialize
,
E
:
std
::
fmt
::
Display
,
{
self
.maybe_accept
();
let
conn_closed
=
match
self
.close_notify
.as_ref
()
.map
(|
cn
|
cn
.handle
())
{
Some
(
cn
)
=>
cn
,
None
=>
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment