Skip to content

WS pubsub example. #126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 25, 2017
Merged

WS pubsub example. #126

merged 3 commits into from
Apr 25, 2017

Conversation

tomusdrw
Copy link
Contributor

@tomusdrw tomusdrw commented Apr 24, 2017

  • Exposing futures::sync::mpsc::Sender in RequestContext
  • Apparently ws::Sender doesn't track if the connection is still active so I've added manual tracking and exposed it in RequestContext.
  • Updates all examples to avoid glob imports (only jsonrpc_core is imported with a wildcard)

Closes: #120

@faern
Copy link
Contributor

faern commented Apr 24, 2017

@tomusdrw Not using wildcard imports (use jsonrpc_core::*;) would make it easier for newcomers to track where types used in the example come from.

@tomusdrw
Copy link
Contributor Author

@faern Thanks for the suggestion. Updated all examples.

@faern
Copy link
Contributor

faern commented Apr 24, 2017

@tomusdrw Is the add_method/add_subscription or the macros approach the preferred usage of this crate? Are both meant to be supported for a long time? I got the impression that the macros support is the new kid on the block and was a bit surprised that the new example then uses the other way.

@tomusdrw
Copy link
Contributor Author

pubsub crate is more low-level (works on raw Param, Value and method level), since it's a custom extension to JSON-RPC protocol we want to keep it separate.

macros crate is designed to create a complete services on top of those low-level crates, but uses a bit of macro magic currently.

That said both methods are equally supported, our main driver for this library is development of RPC interfaces in https://github.com/paritytech/parity and we actually use macros there.

The example uses add_method stuff cause it's in pubsub crate, feel free to add another example in macros crate to show WS + PubSub + Macros.

@faern
Copy link
Contributor

faern commented Apr 25, 2017

Using macros instead was pretty easy. I don't think there is any information there that is not already available in the existing PubSub + Macros examples. Getting this merged as is with the added Sender/RequestContext functionality will satisfy my needs for now.

@tomusdrw tomusdrw merged commit 935df6c into master Apr 25, 2017
@tomusdrw tomusdrw deleted the ws-pubsub branch April 25, 2017 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants