Open mDuo13 opened 2 years ago
I have a slightly different implementation here: https://github.com/XRPLF/xrpl-py/blob/sidechain/xrpl/asyncio/clients/websocket_base.py#L137 It's on a separate branch for now, but it'll likely be merged in the next month or so.
For posterity, here's the commit: https://github.com/XRPLF/xrpl-py/commit/677a94be663e21347aa841ef1662a58d34686e2a
I don't plan on adding this feature, as it would need to be well-tested. I implemented this as a part of a previous sidechain design; it is no longer necessary.
The way xrpl.js lets you do requests and event handlers with the WebSocket client is pretty handy. It would be nice if xrpl-py's sync WebSocket client supported something similar, with
.request(cmd, callback)
and.on(event_type, callback)
methods.I implemented a basic form of this as follows, though it's not quite production ready (it doesn't support multiple
.on()
callbacks nor.off()
, it doesn't enforce types, etc.):To use this, you do something like this:
You can of course define more detailed handlers and pass them by name instead of using
lambda
s.